Created
April 17, 2009 06:58
-
-
Save Monomachus/96892 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
int main (int argc, const char * argv[]) { | |
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; | |
const char *monthArray[12] = {"January", "February", "March", "April", | |
"May", "June", "July", "August", | |
"September", "October", "November", "December"}; | |
if (argc > 0) | |
{ | |
for (int i = 1; i< argc; i++) { | |
int index = (int) strtol(argv[i], NULL, 10); | |
if (index < 1 || index > 12) | |
{ | |
NSLog(@"ERROR: Incorrect month index."); | |
return 1; | |
} | |
NSLog(@"The %drd month is %s", index, monthArray[index-1]); | |
} | |
} | |
else { | |
NSLog(@"Introduce a diggit to obtain the name of the month"); | |
return 1; | |
} | |
[pool drain]; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment