Dear All,
i have doubt in working of scanf:-
if i give input as 123456 44 544Code:void main()
{
int a,b,c;
scanf("%1d %2d %3d",&a,&b,&c);
printf("Sum=%d",a+b+c);
}
output is = 480
How it is possible?
Printable View
Dear All,
i have doubt in working of scanf:-
if i give input as 123456 44 544Code:void main()
{
int a,b,c;
scanf("%1d %2d %3d",&a,&b,&c);
printf("Sum=%d",a+b+c);
}
output is = 480
How it is possible?
1+23+456 = ?
find out whats happening by printing out the values of a,b,c respectively
not %1d %2d %3dCode:scanf("%d %d %d",&a,&b,&c);
fflush(stdin);
learn about padding...