struct recordNode {
char district[50];
int employees;
int employers;
int students;
int retried;
int others;
struct recordNode* left;
struct recordNode* right;
};
FILE *getFile (char filename[]) {
struct recordNode* node;
FILE* fpin;
FILE* fpout;
char line_buffer[lineSize]; /* BUFSIZ is defined if you include stdio.h */
int counter = 0;
filename = "testData.txt";
//file validation
fpin=fopen("testData.txt", "r");
if (fpin == NULL) exit(0);
counter = 0;
while (fgets(line_buffer, sizeof(line_buffer), fpin)) { /* same as while (feof(in) != 0) */
counter++;
if (counter != 0) {
//Central & Western - Chung Wan,7576,1042,2156,1875,3154 (sample data)
sscanf(line_buffer, "%s,%d,%d,%d,%d", node->district, node->employees, node->students, node->retried, node->others);
printf("%s", node->district); **//error**
}
getchar();
}
getchar();
return fpout;
}
我編譯時出錯,我的代碼出了什麼問題?有一個錯誤信息 項目Project1.exe引發的異常類EAccessViolation與消息....................(borland C++)從文件中拆分文本
編譯時不會出現該錯誤,您在運行時會得到該錯誤。請學會準確。 – 2011-06-07 16:04:00