A Collection of Code Snippets in as Many Programming Languages as Possible
This project is maintained by TheRenegadeCoder
Welcome to the Capitalize in Objective C page! Here, you'll find the source code for this program as well as a description of how the program works.
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSLog(@"Enter the text to be capitalized: ");
NSString* textFromStdin = [[NSString alloc] initWithData:[[NSFileHandle fileHandleWithStandardInput] availableData] encoding:NSUTF8StringEncoding];
NSString* normalizedText = [textFromStdin stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]];
if([normalizedText length] < 1){
NSLog(@"Usage: please provide a string");
return 0;
}
NSString *firstChar = [[normalizedText substringToIndex:1] uppercaseString];
NSString *remainingText = [normalizedText substringFromIndex:1];
NSString *capitalizedText = [firstChar stringByAppendingString:remainingText];
NSLog(@"%@", capitalizedText);
return 0;
}
return 0;
}
Capitalize in Objective C was written by:
If you see anything you'd like to change or update, please consider contributing.
No 'How to Implement the Solution' section available. Please consider contributing.
No 'How to Run the Solution' section available. Please consider contributing.