+ 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

22nd Jul 2020, 4:22 PM
S.Brindha
S.Brindha  - avatar
3 Antworten
+ 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..
22nd Jul 2020, 4:43 PM
Jayakrishna 🇮🇳
+ 1
You can try to type cast the integer to a char and then read it: https://code.sololearn.com/cjQyyU70TpaC/?ref=app
22nd Jul 2020, 4:25 PM
Aaron Eberhardt
Aaron Eberhardt - avatar
0
%d integer %c character %f floating point %s string %u unsigned S.Brindha
22nd Jul 2020, 5:02 PM
Sâgærāvürï
Sâgærāvürï - avatar