Me and My Muse

Wednesday, August 30, 2006

Usage of assignment suppression operator in scanf ..

Suppose you have some crap input, then what normally we do is take a dummy variable and scan the input in that variable ..

for example if you have to scan a integar which is of no use .. then what you do is
int dummy


scanf(ā€%dā€,&dummy);

but there is one more method which can save memory and time

what you do is

scanf(ā€%*dā€);

In this method .. we provide a character * to the scanf function and by doing that .. scanf will scan the input from standard input .. but it wont assign it to any variable .. ( this is scanned in a buffer of sufficient size .. and you dont have to worry about that ) ..

Labels:

0 Comments:

Post a Comment

<< Home