Created
February 16, 2014 15:30
-
-
Save yoman07/9036078 to your computer and use it in GitHub Desktop.
Atoi objective-c
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
- (int) atoi:(char *) str { | |
if(!str) | |
NSLog(@"Enter valid string"); | |
int result = 0; | |
char *p = str; | |
while((*p>='0') && (*p<='9')) { | |
result = result*10 + (*p - '0'); | |
p++; | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment