fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <limits.h>
  4. #include <math.h>
  5.  
  6. int main(void) {
  7. char ch, ch1, ch2, ch3, ch4;
  8. ch = 'a';
  9.  
  10. unsigned short int;
  11.  
  12. double b = INFINITY;
  13.  
  14. short u;
  15. char c;
  16. float f;
  17.  
  18. printf("%c\n", ch);
  19.  
  20. printf("%d\n", ch);
  21.  
  22. printf("%d\n", SHRT_MAX);
  23.  
  24. printf("%lf\n", b);
  25.  
  26. printf("Enter char int char float: \n");
  27. scanf("%c %d %c %f", &ch1, &u, &ch2, &f); // This line reads correctly. Ex.
  28. // a 5 b 5.5
  29. printf("You entered: %c %d %c %0.3f\n", ch1, u, ch2, f);
  30.  
  31. printf("Enter char float int char: \n");
  32. scanf("%c%f%d%c", &ch3, &f, &u, &ch4); // This line reads 5.5 5 a
  33. // Here is where the first %c
  34. // is being read as a white space.
  35. printf("You entered: %c %0.3f %d %c\n", ch3, f, u, ch4);
  36. return 0;
  37. }
Success #stdin #stdout 0s 4420KB
stdin
a 1 b 2.5
c 2.0 5 f
stdout
a
97
32767
inf
Enter char int char float: 
You entered: a 1 b 2.500
Enter char float int char: 
You entered: c 2.000 5