[prog] Learning C Question

Gareth Anderson Gareth.Anderson at acslink.net.au
Mon Oct 31 09:56:28 EST 2005


On 10/31/05, Gretchen Dziengel <gdziengel at gmail.com> wrote:
>
> And now that it's been pointed out to me, I can see that none of the
> examples in my book have \n in the scanf lines. Oops!
> Thanks everybody, I'm sure I'll be back again.
>

This problem is very common in C programming. People avoid using scanf and
use functions like getf() etc (you'll get to them, its being 2 years since
I've done C programming).

Also getc() is an easy way to get rid of a newline character thats still in
the buffer....

What scanf does is read from a buffer, you were getting the extra
information in the buffer and using it, making everything mess
up...(although my knowledge of C is a little weak now)

Regards,
Gareth


More information about the Programming mailing list