Advertisement
paulogp

String para número

Jul 13th, 2011
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.30 KB | None | 0 0
  1. // Apple Xcode
  2.  
  3.  
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <string.h>
  7.  
  8. int main (int argc, const char * argv[])
  9. {
  10.     // string to num
  11.     char *the_string = malloc(8);
  12.  
  13.     strcpy(the_string, "123");
  14.  
  15.     int the_int = atoi(the_string);
  16.  
  17.     printf("%s para %i\n", the_string, the_int);
  18.  
  19.     return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement