开发者

Unable to open file in C

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜