Code:
int main(int argc, char *argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSString *fullAlphabet = @"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
NSRange positionOfC = [fullAlphabet rangeOfCharacterFromSet:[NSCharacterSet characterSetWithCharactersInString:@"C"]];
NSString *alphabetFromC = [fullAlphabet substringFromIndex:positionOfC.location];
NSLog(@"The result is: %@",alphabetFromC);
[pool drain];
return 0;
}
The @"C" would be replaced with a string containing the entered character. There's other tomfoolery you could do with math on characters (ASCII code business.... pos = myChar - 'A', etc.), but this should work, and it's only a few lines
-Lee
Edit: You asked for the characters in an array. Not sure why, an NSString seems better, but you could toss this before the [pool drain]:
Code:
unichar *alphaList = (unichar *)malloc([alphabetFromC length]*sizeof(unichar));
[alphabetFromC getCharacters:alphaList];
int x;
for(x = 0;x < [alphabetFromC length];x++) {
NSLog(@"Position %d is %C",x,alphaList[x]);
}
free((void *)alphaList);
An NSArray can't hold unichars... so a C-style array it is.