I'm trying to teach myself Objective-C/Cocoa for eventual iPhone development but I figured I would start with a terminal app. It takes a user input, strips everything but numerics, then displays PI to the number that is left over.Could anyone have a quick look over my code and see if there's any optimisations I could make or bad practises I could avoid?#import <Foundation/Foundation.h>int main(int argc, const char * argv[]){    @autoreleasepool {        int i;        char userInput[10];        printf (Enter a number: );        scanf(%s,userInput);        NSString * number = [NSString stringWithUTF8String:userInput];        NSString * strippedNumber = [number stringByReplacingOccurrencesOfString:@[^0-9] withString:@ options:NSRegularExpressionSearch range:NSMakeRange(0, [number length])];        i = [strippedNumber intValue];        printf(%d\n, i);        if (i == 0) {            printf(Enter a numeric character\n);        }        else {            printf(%.*f \n, M_PI, i);        }    }    return 0;}
Pi to the Nth Digit
beginner;objective c;floating point
BTW: I'm answering from a strong C perspective and weak Objective-C oneTo avoid unexpected input and avoid string overflow://scanf(%s,userInput);if (1 != scanf(%9s,userInput)) handle_error();I'm sure you want:ref// printf(%.*f \n, M_PI, i);printf(%.*f \n, i, M_PI);