www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/01/15/10:39:30

Date: Thu, 15 Jan 1998 16:34:10 +0100 (MET)
From: Olivier Perron <perron AT art DOT alcatel DOT fr>
To: HackerOC3 <hackeroc3 AT aol DOT com>
Cc: djgpp AT delorie DOT com
Subject: Re: parse errors
In-Reply-To: <19980115130300.IAA15160@ladder01.news.aol.com>
Message-Id: <Pine.GSO.3.96.980115162808.814A-100000@rtbsci143s>
Mime-Version: 1.0

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019