Possible scanf bug?

C Code. C Code run. cs163wcr at sdcc10.ucsd.edu
Wed Jan 30 08:08:46 AEST 1991


Is this a bug, or am I just using scanf wrong?  I'm trying to
make scanf read a line that's ended with newline.

char buffer[100];	/* Line won't be over 80, but so what */
scanf ("%[^\n]%*c",buffer);

If it reads an empty line, buffer isn't changed at all!  It should
make buffer the null string!  Right?

Steve Boswell
whatis at ucsd.edu



More information about the Comp.lang.c mailing list