Message-ID: <360FCDC1.FB7B8A6F@ime.unicamp.br> Date: Mon, 28 Sep 1998 14:56:17 -0300 From: "Renato Fernandes =?iso-8859-1?Q?Cant=E3o?=" Organization: UNICAMP MIME-Version: 1.0 To: djgpp AT delorie DOT com Subject: Re: Strange DJGPP bug References: Content-Type: multipart/mixed; boundary="------------F890E53DC427A60BECC2D3C4" Precedence: bulk This is a multi-part message in MIME format. --------------F890E53DC427A60BECC2D3C4 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi Friends! Just a warning: it will happen too if you're using C++ and related structures like "cout", "cin" or "cerr". Just in case, (or need!) use: cout.flush(); 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. > --------------F890E53DC427A60BECC2D3C4 Content-Type: text/x-vcard; charset=us-ascii; name="cantao.vcf" Content-Transfer-Encoding: 7bit Content-Description: Card for Renato Fernandes Cantão Content-Disposition: attachment; filename="cantao.vcf" begin:vcard n:Cantão;Renato Fernandes x-mozilla-html:FALSE org:State University at Campinas;Dept. of Applied Mathematics - IMECC adr:;;;Campinas;São Paulo;;Brazil version:2.1 email;internet:cantao AT ime DOT unicamp DOT br title:MSc. fn:Cantão! end:vcard --------------F890E53DC427A60BECC2D3C4--