Posted by Matthew Pratt on 1999-03-30
--- Morgan Terry <morgan@xxxxxxxxxxx.xxx> wrote:
> Hey
> I have a function where I am using printf and fgets
> to prompt for and
> get input. If I use flushall() before my printf
> calls, it works, but
> only in Borland C++ v4.52. When I try it w/ djgpp,
> it complains with
> "undeclared reference to 'flushall'"
> I am compiling w/ the following command line: gcc -o
> budget.exe budget.c
>
flushall() sounds to me like a non-standard call that
Borland made up themselves.
> If I don't use the flushall(), though, it doesn't
> work right. It acts
> like it's skipping some of my fgets() calls, maybe
an
> extra newline in
> one of the streams?
>
> I would like to know what buffers I need to flush(I
> don't want to use
> flushall() if it isn't portable), and also, if
anyone
> could point me to
> a better way of prompting for and getting the input,
> I would be
> interested in that as well.
Try the fflush call instead. It is prtable as it is
part of the standard UNIX API.
FFLUSH(3) Linux Programmer's Manual
FFLUSH(3)
NAME
fflush - flush a stream
SYNOPSIS
#include <stdio.h>
int fflush(FILE *stream);
DESCRIPTION
The function fflush forces a write of all
buffered data
for the given output or update stream via the
stream's
underlying write function. The open status of
the stream
is unaffected.
If the stream argument is NULL, fflush flushes
all open
output streams.
RETURN VALUES
Upon successful completion 0 is returned.
Otherwise, EOF
is returned and the global variable errno is set
to indicate the error.
Hope this helps.
===
Matty .
http://members.xoom.com/mattpratt/ _--_|\
mattpratt@xxxxx.xxx / \
s3099239@xxxxxxx.xxx.xxx.xx \_.--._/<--Canberra,
W2K - The other millenium bug. v Australia
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
Previous post | Next post | Timeline | Home