Mail Archives: djgpp/1998/01/15/10:39:30
On 15 Jan 1998, HackerOC3 wrote:
> printf("y value?");
> int y;
> scanf(" %d", &y);
> printf("color value?");
> int c;
> scanf(" %d", &c);
>
> In above code, i get parse errors before int. I also sometimes get parse
> errors in function prototypes for seemingly invaild reasons. Please help!!
>
In C, you have to first define your local variables and only *after* you
can write your statements.
By the way, the DJGPP port of gcc use buffered IO streams. So, I recommend
you to force your printf output with fflush. See the FAQ for further
details.
Try the following code:
int main(void)
{
int y;
int c;
printf("y value?");
fflush(stdout);
scanf(" %d", &y);
printf("color value?");
fflush(stdout);
scanf(" %d", &c);
exit(0);
}
- Raw text -