I'm really new to Objective C and am trying to write a program to go through the collatz conjecture. When I run the program, it stops after the first scanf and comes up with "EXC_BAD_ACCESS". Here's my code:
int original,i;
NSString *PrintFull;
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
NSLog(@"Collatz Conjecture:");
NSLog(@"Print full results?");
scanf("%s",PrintFull);
NSLog(@"What number should we go up to?");
scanf("%d", &original);
while (original <= 100) {
NSLog(@"\n\n%d", original);
i = original;
while (i != 1) {
if (i % 2) {
i = (i*3)+1;
} else {
i = (i/2);
}
if ([PrintFull isEqualToString:@"yes"]) {
NSLog(@"%d",i);
}
}
original++;
}
}
What am I doing wrong here?