Calling a global string variable from Fortran in C causes segmentation fault
问题 I'm trying to call a global string variable which is defined in a Fortran subroutine, in C. the C code is Cfile.c : #include <stdio.h> typedef struct { int length; char* string; } fstring; extern fstring stringf_; void fortfunc_(); int main() { fstring stringC = stringf_; stringC.string[stringC.length-1] = '\0'; printf("%s \n",stringC.string); return 0; } and FORTRAN code is Ffile.f : subroutine fortfunc() character*30 string common/stringF/ string string = 'this is a string in FROTRAN77'