xcode - Thread 1: EXC_BAD_ACCESS (code=1, address=0x0) standard C memory issue

xcode – Thread 1: EXC_BAD_ACCESS (code=1, address=0x0) standard C memory issue

xcode – Thread 1: EXC_BAD_ACCESS (code=1, address=0x0) standard C memory issue

Check the return value of strtok.

In your code here

locTok = strtok(NULL, ..);
posL[pCount].stop = atoi(locTok); //ERROR IS SHOWN HERE

strtok is returning a NULL pointer and according to documentation,

A null pointer is returned if there are no tokens left to retrieve.

which matches my original guess that because the address code is 0x0 theres a NULL pointer deference somewhere.

Obviously, the following call to atoi is expecting a non-NULL pointer and crashes.

You Can Also Use Exception Breakpoint in Xcode.

An exception breakpoint tells the debugger to pause whenever a problem is encountered anywhere in your program, so you can evaluate your programs state before it crashes.

Go to the Breakpoint Navigation (Cmd+8), then click the + button in the bottom left and choose Add Exception Breakpoint. You can leave it there.

enter

xcode – Thread 1: EXC_BAD_ACCESS (code=1, address=0x0) standard C memory issue

for xc

in your main() function, try to remove char*argv[] or both arguments.

Related posts on X code  :

Leave a Reply

Your email address will not be published.