开发者

Unable to open file in C

开发者 https://www.devze.com 2023-02-20 14:11 出处:网络
i am working in C and want to open a simple text file then perform some processing over it. My code looks like

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

精彩评论

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