Re: A simple program , need to see where's the mistake :)
- From: Andrew Poelstra <apoelstra@xxxxxxxxxx>
- Date: Thu, 26 Oct 2006 14:06:36 GMT
On Thu, 2006-10-26 at 12:51 +0000, Christopher Benson-Manica wrote:
Andrew Poelstra <apoelstra@xxxxxxxxxx> wrote:
int num, ctr;
scanf(&num);
What is this, my lord? Surely hell hath no fury like a terribly
incorrect scanf() call?
Oops! I meant
scanf("%d", &num);
My final comment is that you shouldn't be using scanf() for user input,
as it's very unfriendly and doesn't handle erroneous input properly.
Better to write your own get_int() function using fgets() or fgetc(). I
recommend that as your next project.
And you helpfully provided an example of how *not* to use scanf() :-)
:-}
--
Andrew Poelstra <http://www.wpsoftware.net/projects/>
.
- References:
- A simple program , need to see where's the mistake :)
- From: Odinn
- Re: A simple program , need to see where's the mistake :)
- From: Andrew Poelstra
- Re: A simple program , need to see where's the mistake :)
- From: Christopher Benson-Manica
- A simple program , need to see where's the mistake :)
- Prev by Date: Re: define a struct that has its own type as a field somehow?
- Next by Date: va_arg()
- Previous by thread: Re: A simple program , need to see where's the mistake :)
- Next by thread: New to Programming
- Index(es):
Relevant Pages
|