-
December 23rd, 2012, 12:26 AM
#1
C and Fortran mix programming problem
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
***********************
Thanks guys.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|