Re: Beginning programmer... I need some help.
- From: "Vladimir S. Oka" <novine@xxxxxxxxxxxxxxx>
- Date: Sun, 5 Feb 2006 21:59:36 +0000 (UTC)
bmlclemson08 wrote:
OK the new code i have so far is:
#include <stdio.h>
int main ()
{
int current_in, largest_so_far, counter;
printf ("Enter your numbers:\n");
scanf ("%d", &largest_so_far);
for (counter = 0; ; counter = counter + 1)
{
scanf ("%d", ¤t_in);
if (largest_so_far < current_in)
largest_so_far = current_in;
if ((current_in = getchar()) != EOF)
{
break;
}
Here, you break out of `for` loop only if getchar() does /not/ return
EOF, probably not what you wanted. Did you mean to type `==`?
Anyway, read my other post, and try to implement my suggestion. I don't
think you're on the right path here (e.g. your current solution does
not cater for /no/ integers at all).
Cheers
Vladimir
PS
Also keep in mind that your getchar() call "eats" the non-EOF characters
(to pedants: I know EOF is a condition, not a character). You may be
better of using getc() and if it does not return EOF do an ungetc().
--
Very few profundities can be expressed in less than 80 characters.
.
- References:
- Beginning programmer... I need some help.
- From: bmlclemson08
- Re: Beginning programmer... I need some help.
- From: bmlclemson08
- Beginning programmer... I need some help.
- Prev by Date: Re: longjmp issue
- Next by Date: Re: fork()
- Previous by thread: Re: Beginning programmer... I need some help.
- Next by thread: Re: Beginning programmer... I need some help.
- Index(es):
Relevant Pages
|