Advertisement
Guest User

CONVERT STRING TO NUMBER

a guest
May 24th, 2015
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.22 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. void main(void)
  5. {
  6.     char str[6] = "12345";
  7.     unsigned int i = 0, a = 0;
  8.     while (str[i] != NULL && (a+=(str[i] - 48) * pow(10, strlen(str) - i - 1))) i++;
  9.     printf("\n %d \n", a);
  10. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement