这样写问题在哪?
每次到1都直接跳到2而不进循环里~非常确认档案存在~且不是空路径也正确~
程序代码:
#define INIFile "AAA.ini" #define Max_Size 256 char *GetINIFileFullPath() { char *wstr=""; unsigned long size=GetCurrentDirectory(0,NULL); char *path=new char[size]; if(GetCurrentDirectory(size,path)!=0) { strcat(path , "\\"); strcat(path,INIFile) ; wstr=path; } return wstr; } void main(int argc, char* argv[]) { FILE *stream3; char temp[Max_Size]={0}; char *INI=GetINIFileFullPath();// 这行这样写不对吗? stream3 = fopen( INI , "r" ); if( stream3 == NULL ) printf( "The file %s was not opened\n",INI ); else { while(fgets(temp, Max_Size, stream3)!=NULL) //1 { ...... ...... } } fclose(stream3); //2 ...... }