Advertisement
Guest User

Untitled

a guest
Jun 2nd, 2015
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. char STRING[]= "100";
  5.  
  6. int mojatoi(char*ch);
  7.  
  8. int main(void)
  9. {
  10. printf("%d\n",myatoi(STRING));
  11. return 0;
  12.  
  13. }
  14. int myatoi(char*ch)
  15. {
  16. int number=0;
  17. int count=0;
  18. int i;
  19. while(*(ch++)!='\0')
  20. count++;
  21. ch=ch-2;
  22. for (i=0;i<count;i++)
  23. {
  24. number+= (*ch---48)*(int)pow((double)10,(double)i);
  25. }
  26. return number;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement