Advertisement
Guest User

Untitled

a guest
Dec 5th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. /* sscanf example */
  2. #include <stdio.h>
  3.  
  4. int main ()
  5. {
  6. char sentence []="Rudolph is 12 years old";
  7. char str [20];
  8. char str2 [20];
  9. int i;
  10.  
  11. sscanf (sentence,"%s %s %d",str,str2,&i);
  12. //str=Rudolph
  13. //str2=is
  14. //i=12
  15. printf ("%s %s -> %dn",str,str2,i);
  16.  
  17. return 0;
  18. }
  19.  
  20. /* sscanf example */
  21. #include <stdio.h>
  22.  
  23. int main ()
  24. {
  25. char sentence []="5,6,7";
  26. char str [20];
  27. char str2 [20];
  28. int i,j,k;
  29.  
  30. sscanf (sentence,"%d %*c %d %*c %d",&i,&j,&k);
  31. printf ("%d %d %dn",i,j,k);
  32.  
  33. return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement