Loop does not run in Xcode

4

I'm trying to run a loop in Xcode , however it does not work.

The console is:

  

Type the loop number:
  5

Nothing else happens in the terminal. There is no 0.1,2,3,4,5.

In short, it gets stuck after I type any number, but from what I've seen, it's still running, so I have to stop to run it again.

The debug session:

I put a breakpoint on the variables and gave a stepover

Doesthishavetodowith@autoreleasepool?Thesamehappenswithmyswitch.

Mycode

#import<Foundation/Foundation.h>intmain(intargc,constchar*argv[]){@autoreleasepool{inti,usuario;NSLog(@"Digite o numero do loop: ");
        scanf("%i", &usuario);
        for (i=0; i<=usuario; i++) {
             NSLog(@"%i", i);
        }        
     }
 return 0;
}

The project was created in Foundation, Command Line Tool.

    
asked by anonymous 30.04.2014 / 23:10

1 answer

1

Are you sure you do not compute the loop?

I think the error lies in having the variable "%i" which I think should be only "%d" or "%f" to float:

#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]){
     @autoreleasepool {
        int i, usuario;
        NSLog(@"Digite o numero do loop: ");
        scanf("%d", &usuario);
        for (i=0; i<=usuario; i++) {
             NSLog(@"%d", i);
        }        
     }
 return 0;
}

Anyway, please advise for printf's along the code section.

Regards.

    
01.05.2014 / 13:53