Want to highlight a helpful answer? Upvote!

Did someone help you, or did an answer or User Tip resolve your issue? Upvote by selecting the upvote arrow. Your feedback helps others! Learn more about when to upvote >

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

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
Question marked as Best reply

Posted on Feb 20, 2013 9:02 AM

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.

1 reply
Question marked as Best 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.

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 ID.