i am working in C and want to open a simple text file then perform some processing over it. My code looks like
FILE *pFile;
pFile = fopen("d:\\series.txt", "r");
if (pFile == NULL)
{
printf("File not found or Unable to open file\nPress any key to continue . . ." );
getch();
return;
}
开发者_运维技巧 else
{
//process here
}
every time the condition becomes true if (pFile == NULL) so i am not able to perform processing on file.
I check that file exist in my drive with same name and its open properly when i double click on it
Try putting this inside the if
block:
perror(NULL);
That should give a descriptive error message, so you know what went wrong.
精彩评论