Advertisement
Guest User

Untitled

a guest
Jul 19th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3.  
  4. int main()
  5. {
  6. char *str = "Tom 28";
  7. char name[10];
  8. int age, ret;
  9.  
  10. printf("str= %sn", str);
  11. ret = sscanf(str, "%s %d", name, &age);
  12. printf("Name: %sn", name);
  13. printf("Age: %dn", age);
  14.  
  15. str[12] = '5';
  16.  
  17. printf("str= %sn", str);
  18. ret = sscanf(str, "%s %d", name, &age);
  19. printf("Name: %sn", name);
  20. printf("Age: %dn", age);
  21.  
  22. exit( 0 );
  23. }
  24.  
  25. str= Tom 28
  26. Name: Tom
  27. Age: 28
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement