delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/04/10/18:41:12

Sender: <jacasey AT bajor DOT its DOT deakin DOT edu DOT au>
From: jacasey DOT invalid AT bajor DOT its DOT deakin DOT edu DOT au
Subject: Re: fflush(stdin); /*doesn't seem to work in dos? */
Newsgroups: comp.os.msdos.djgpp
References: <6uhI4.60$ie DOT 11883 AT news DOT deakin DOT edu DOT au> <83r9cdag0m DOT fsf AT mercury DOT st DOT hmc DOT edu>
User-Agent: tin/1.5.2-20000206 ("Black Planet") (UNIX) (SunOS/5.7 (sun4u))
Lines: 37
Message-ID: <zLsI4.69$ie.12134@news.deakin.edu.au>
Date: Mon, 10 Apr 2000 22:40:31 GMT
NNTP-Posting-Host: 139.132.19.1
X-Trace: news.deakin.edu.au 955406431 139.132.19.1 (Tue, 11 Apr 2000 08:40:31 EST)
NNTP-Posting-Date: Tue, 11 Apr 2000 08:40:31 EST
Organization: Deakin University, Victoria, Australia
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Nate Eldredge <neldredge AT hmc DOT edu> wrote:
> jacasey DOT invalid AT bajor DOT its DOT deakin DOT edu DOT au writes:

>> yeah as the subject says fflush(stdin); doesn't seem to work in dos or
>> djggp, any thoughts?

> According to ANSI, fflush(stdin) has undefined behavior, so
> technically, no matter what happens, DJGPP is still correct.  In
> practice, it just does nothing (IIRC).

> But that doesn't help you.  What did you want to accomplish by this?
> There is almost certainly a correct way to do it.


Okay heres the offending code snippet:

there seems to be a loose CR character in there somewhere, the first loop
goes fine and then after the second it completely skips my first gets();  
btw.  fflush(stdin); works quite nicely on unix (sun), I guess its just
not completely ansi compliant.

void get_job(QUEUE *queue) 
{
	int count;
	ELEMENT job_buffer;
	for(count=0;count <MAX_QUEUE;count++)
	{
		fflush(stdin);
                printf("Enter job description: ");
                gets(job_buffer.job_des);
		printf("Enter job number: ");
                scanf("%d",&job_buffer.job_num);
		printf("Enter job priority: ");
		scanf("%d",&job_buffer.job_pri);
		insert(job_buffer,queue);
        }
}

- Raw text -


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