Hi all, I need to call a function written in Fortran from C for recent work. Because I have no such experience before, I start with a toy program as follows.
However when it runs, there is a '0' before 'END', as in the following pic. I want to ask where it is from.
********************
The C code is
#include <stdio.h>
#include <math.h>
extern int add_(int * ,int *);
int main()
{
int a,b;
int z;
a=2;
b=3;
printf("a=%d,b=%d",a,b);
z=add_(&a,&b);
printf("%d\n",z);
printf("END\n");
}
************************
The fortran code is
INTEGER FUNCTION ADD (A, B)
INTEGER A, B
INTEGER C
WRITE (*,*) 'IN FORTRAN'
WRITE (*,*) 'A=',A,'B=',B
C=A+B
WRITE (*,*) 'FINISH ADD',C
RETURN
END
Bookmarks