#include #include struct source_files{ FILE *fpt; char *path; int stat; }; void open_struct_file( struct source_files *da){ printf("in fun %s\n",da->path); da->fpt=fopen(da->path,"ab+"); if(!da->fpt) da->stat=0; // false else da->stat=1; // true } int main(int argc, char **argv){ struct source_files sf; char *path; if(argc==1){ sf.path="data.dat"; open_struct_file(&sf); if(sf.stat){ printf("file open %d\n",sf.stat); }else{ printf("file not open %d\n",sf.stat); exit(1); } } else if (argc==2){ path=strdup(argv[1]); //printf("%s\n",path); FILE *ff = fopen(path,"ab+"); if(!ff){ printf("file not open\n"); exit(1); }else{ printf("file open\n"); } } return 0; }