I was playing with width field for printf and scanf in C but I'm rather confused by it.
I tried the following code :-
It prints 24 but as far as I understood it should only print 2 as I told to print only 1 character.Code:int N = 24; printf ("%1d", N);
Now this code :-
In this if I input 24 it prints 2 as it only scans 1 character.Code:int N; scanf ("%1d", &N); printf ("%d", N);
Why didn't the first code work?