Skip to content

Instantly share code, notes, and snippets.

@Monomachus
Created April 17, 2009 06:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Monomachus/96892 to your computer and use it in GitHub Desktop.
Save Monomachus/96892 to your computer and use it in GitHub Desktop.
#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