On Tue, 09 Apr 2002 04:28:28 GMT,
Derek Winkler <dwinkler@NOSPAMcomcast.net> wrote:
> In the following bit of code, I have a slight problem. In my example, i is
> 0. When it gets to the switch and I press N, it prints "Type new name for
> this item:" to the screen. However, when I go to start typing the new name,
> nothing happens until I press N again, at which time it reprints the message
> and lets me type in a name. After I type in the name, though, and hit ENTER,
> the program locks up and I have to exit with CTRL+BREAK. If i is anything
> other than 0, the program runs into an error and exits.
>
> int i,b,a;
> . . . . . . (a few lines of printfs and stuff) . . . . . .
> do {
> switch(toupper(getch())) {
getch() blokerer vel, indtil der kommer et tegn.
> case 'N': printf("Type new name for this item: ");
> gets(item[i].name);
Her læser du alt hvad der bliver skrevet.
> break;
> case 'P': printf("Enter Bidder's Number: ");
> scanf("%d",&a);
> item[i].bidder=a-1;
> printf("Enter Price: ");
> scanf("%d",&item[i].price);
> break;
> case 'C': return;
> break;
> }
> } while(!(kbhit()));
Og her looper du, hvis der ikke er mere at læse, hvilket der ikke er da
du lige har læst det hele.
Prøv med: while(false); i stedet
--
Like a rat in a maze Anders Bo Rasmussen mailto:fuzz01@spamfilter.dk
The path before me lies Frimestervej 42 1.tv
http://www.fuzz.dk
And the pattern never alters 2400 Kbh. NV
Until the rat dies.