Mail Archives: djgpp/2000/04/10/18:41:12
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 -