Guest User

Untitled

a guest
Feb 21st, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. int string2int(string thestring) {
  2. int result = 0;
  3.  
  4. for(int i=0; i<thestring.length(); i++)
  5. if(thestring[i] >= '0' && thestring[i] <= '9')
  6. result = (result * 10) + (thestring[i] - '0');
  7.  
  8. if(thestring[0] == '-')
  9. result = 0 - result;
  10.  
  11. return result;
  12. }
Add Comment
Please, Sign In to add comment