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 Antworten
+ 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