+ 1
why it is showing error
if a program has scanf("%d",&a) when i give character input why cant it take the asccii value of the character which is an int and store it in a instead showing error eg if i give input as A its ascii value 65 can be stored in a why there is an error
3 Answers
+ 2
First it will search input for required format as you specified in "as %d search for integer, %c for char,..." next it will cast the value taken into variable date types if possible...
Mention %c, it accepts but give you warning..
+ 1
You can try to type cast the integer to a char and then read it:
https://code.sololearn.com/cjQyyU70TpaC/?ref=app
0
%d integer
%c character
%f floating point
%s string
%u unsigned
S.Brindha