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