0
I couldn't display char value in my C code. What's the problem in my coding. Can anyone explain ???
#include <stdio.h> int main(void){ Â int a; Â float b; Â double c; Â char d; Â Â printf("Enter int \n "); Â scanf("%d",&a); Â Â printf("Enter float \n "); Â scanf("%f",&b); Â Â printf("Enter double \n"); Â scanf("%lf",&c); Â Â printf("Enter \n"); Â scanf("%c",&d); Â Â printf("\nint is %d\n",a); Â printf("float is %f\n",b); Â printf("double is %lf\n",c); Â printf("\nvalue is %c",d); Â Â return 0; }
2 Answers
+ 2
Add a space before %c to catch remaining white space characters '\n' left in the input stream from previous inputs in this line
scanf(" %c",&d); <--- add space like this