Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int my_atoi(const char* src)
- {
- int result = 0;
- int digit = 1;
- const int DIGIT_DIFFERENCE = 10;
- const char ZERO_SYMBOL = '0';
- for(int i = (strlen(str)-1); i >= 0; i--)
- {
- result = result + (digit * int(str[i]-ZERO_SYMBOL));
- digit = digit * DIGIT_DIFFERENCE;
- }
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement