calling C function from program.
Ganesh Ramakrishnan
gangesind@yahoo.com
Fri Feb 15 06:39:00 GMT 2002
sir/madam,
I am facing some problem, when i call a C
function from a fortran program & compile it using
g77.
Here is my fortran program ---->
------------------------------------------------------
program hello
call callC("calling C program")
print *, "hai"
end
-------------------------------------------------------
Here is my C function ---------->
-------------------------------------------------------
callC_(x)
char* x;
{
printf("%s\n", x);
}
----------------------------------------------------
Now if i compile this with g77, I am getting the
output like this
-----------------------------------------------------
calling C programhai
hai
------------------------------------------------------
The argument which i am passing to the C
function("calling C program") is appended with the
output of the next 'print' statement("hai"). if i
append '\0' at the end of that argument("calling C
program\0"), then it is working fine. Why is it like
this.
I am compiling the program like this.
---------------------------------------------------
g77 "fortran file" "c file"
Will you please suggest me the right way to call
a C function from fortran program?
Expecting your earliest reply.
Thanking you,
R.Ganesh
__________________________________________________
Do You Yahoo!?
Got something to say? Say it better with Yahoo! Video Mail
http://mail.yahoo.com
More information about the Gcc-help
mailing list