Message-Id: <360E34C7.387F@cableol.co.uk> Date: Sun, 27 Sep 1998 13:51:19 +0100 From: Allens Mime-Version: 1.0 To: Test User Cc: djgpp AT delorie DOT com Subject: Re: Strange DJGPP bug References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Precedence: bulk Test User wrote: > > Here's a short C program: > > #include > > int main() > { > char buffer[256]; > > printf("Input: "); > fgets(buffer, 255, stdin); > printf("\nYou typed %s\n"); > } > > When compiled with the Linux version of GCC, this program > prints an Input: prompt. When the user types something and > presses ENTER, it then prints the string the user typed, > in the form of "\nYou typed %s\n", where \n is a newline and > %s is the string the user typed, including the trailing newline. > > When compiled with DJGPP, the program just sits there until > the user types something and presses ENTER. Then, the > program spews out the Input: prompt and the string the > user typed at the same time. For some reason, it executes > fgets() first, and then executes both printf's together. You > can't get it to print the prompt first, then call fgets(), > and then print the results. You can substitute fgets() for > your own elaborate loop system. You'll get the same result. To save time switching between protected mode and dos, djgpp is buffered, so the easiest way to make it print something on the screen is to add \n to the end of printf ("input:") line. Peter Allen