Xcode: lost connection with Error code -1
This seemingly trivial piece of code is copied from the textbook but after
Xcode takes the input at the scanf(), the program exits with error code -1
and says "lost connection".
#import <Foundation/Foundation.h>
int main (int argc, char *argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc]init];
int number;
NSLog(@"Type in your number: ");
scanf("%i", &number);
if (number < 0)
number = -number;
NSLog(@"The absolute value is: %i", number);
[pool drain];
return 0;
}
No comments:
Post a Comment