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?
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 = ?
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
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...
Last edited by creeping death; 03-20-2009 at 01:33 PM.