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