C file handling on xcode 3.2.3

Hi all

I am opening a file that does not exists.

But after i got message File does not exists,

gdb does not stop.What should i do?

Suggestions are welcome.

Thanks.


my program:


int main (int argc, const char * argv[])

{

FILE* fd;

fd = fopen("abc123.txt", "r");


if(NULL == fd)

{


printf("File does not exists\n");


return -1;

}

printf("File Opened\n");

return0;

}

And here is the output:


Not a file


Debugger stopped.

Program exited with status value:255.The program being debugged is not being run.

The program being debugged is not being run.

(gdb)

Mac mini, Mac OS X (10.6.4)

Posted on Feb 19, 2013 11:18 PM

Reply
1 reply

Feb 20, 2013 9:02 AM in response to Dhiraj Bhor

The program didn't encounter a debugable error. The fopen failed to open the file, the file pointer was checked for a Null value (which is what is returned by an fopen failing in some way and then the program terminated with a -1 (255 to the terminal)


If you want to run the debugger when this happens you will need to set a breakpoint after the fopen and before the return.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

C file handling on xcode 3.2.3

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.