C FILE * 没有值也没有错误
C FILE * with no value and no error
我在读取文件时遇到了一个小问题。代码在下面。我试过这个 http://www.tutorialspoint.com/cprogramming/c_error_handling.htm 来检查错误,但没有任何错误。该文件位于正确的位置并且具有正确的名称。
当我尝试打开它时,它的值为 1,结构的所有成员都具有以下值 "Unable to read memory"
有什么想法吗?
struct node * fileToLinkedList(char * filename) {
FILE * inputFile;
inputFile = fopen(filename, "rb");
if (inputFile =! NULL) {
struct program * programPTR;
struct node * listStart = NULL;
while ((programPTR = getProgramFromFile(inputFile)) != NULL)
addProgramToList(&listStart, programPTR);
fclose(inputFile);
return listStart;
}
else {
errorMessage("File error", "Error opening the file for reading the TV guide", 0);
return NULL;
}
}
inputFile =! NULL
应该是:
inputFile != NULL
我在读取文件时遇到了一个小问题。代码在下面。我试过这个 http://www.tutorialspoint.com/cprogramming/c_error_handling.htm 来检查错误,但没有任何错误。该文件位于正确的位置并且具有正确的名称。
当我尝试打开它时,它的值为 1,结构的所有成员都具有以下值 "Unable to read memory"
有什么想法吗?
struct node * fileToLinkedList(char * filename) {
FILE * inputFile;
inputFile = fopen(filename, "rb");
if (inputFile =! NULL) {
struct program * programPTR;
struct node * listStart = NULL;
while ((programPTR = getProgramFromFile(inputFile)) != NULL)
addProgramToList(&listStart, programPTR);
fclose(inputFile);
return listStart;
}
else {
errorMessage("File error", "Error opening the file for reading the TV guide", 0);
return NULL;
}
}
inputFile =! NULL
应该是:
inputFile != NULL