Advertisement
paulogp

scanf

Jul 18th, 2011
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.54 KB | None | 0 0
  1. // apple xcode
  2. // paulogp
  3. /* scanf */
  4. #include <stdio.h>
  5. #include <stdlib.h> // atoi
  6.  
  7. int main (int argc, const char * argv[])
  8. {
  9.     char the_name[20];
  10.     int the_age;
  11.    
  12.     printf("indique o seu nome: ");
  13.     scanf("%s", &the_name);
  14.    
  15.     printf("indique a sua idade: ");
  16.     scanf("%i", &the_age);
  17.    
  18.     printf("nome apresentado: %s, idade: %i!\n", the_name, the_age);
  19.    
  20.     char the_string_num[2] = "12";
  21.     the_age = atoi(the_string_num);
  22.     printf("string para inteiro: %i!\n", the_age);
  23.    
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement