Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #9843

Re: fflush

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail
NNTP-Posting-Date Thu, 01 Sep 2011 18:14:41 -0500
Message-ID <4E6011E1.292A@mindspring.com> (permalink)
Date Thu, 01 Sep 2011 19:14:41 -0400
From pete <pfiland@mindspring.com>
Reply-To pfiland@mindspring.com
Organization PF
X-Mailer Mozilla 3.04Gold (WinNT; I)
MIME-Version 1.0
Newsgroups comp.lang.c
Subject Re: fflush
References <4e5fe3b1$0$27973$bbae4d71@news.suddenlink.net>
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
Lines 33
X-Usenet-Provider http://www.giganews.com
NNTP-Posting-Host 4.154.223.242
X-Trace sv3-dfbVoG/WxVpBB4T2BTqHzmuwWW10KmBRDqBP2+FPMrYlNVZMDgWgaIceC6N0ALt8Rc4hNN4F9HLNhqd!4ErcONsbsf86m5fHRVF6d26vvJxLYSGfyvcG6rLM2HY0kJ6KL2deAaUa0kPjXbZ2u08MvUJp93Wp!uooG8PPS3jU=
X-Abuse-and-DMCA-Info Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info Otherwise we will be unable to process your complaint properly
X-Postfilter 1.3.40
X-Original-Bytes 1623
Xref x330-a1.tempe.blueboxinc.net comp.lang.c:9843

Show key headers only | View raw


Bill Cunningham wrote:
> 
>     Where is the right place to put fflush in a file IO operation?

If you want a message to appear on standard output,
which asks the user for input,
then use fflush(stdout) after the message code,
before the input code.

/* BEGIN new.c */

#include <stdio.h>

int 
main(void)
{
    int integer;
    
    printf("Enter an integer: ");
    fflush(stdout);
    if (scanf("%d", &integer) == 1) {
        printf("\nThe integer is %d\n", integer);
    } else {
        puts("\nTry harder next time!");
    }
    return 0;
}

/* END new.c */


-- 
pete

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

fflush "Bill Cunningham" <nospam@nspam.invalid> - 2011-09-01 15:57 -0400
  Re: fflush Willem <willem@toad.stack.nl> - 2011-09-01 20:09 +0000
  Re: fflush John Gordon <gordon@panix.com> - 2011-09-01 20:23 +0000
    Re: fflush sandeep <nospam@nospam.com> - 2011-09-01 20:49 +0000
      Re: fflush Kenneth Brody <kenbrody@spamcop.net> - 2011-09-02 10:59 -0400
    Re: fflush Kleuskes & Moos <kleuske@somewhere.else.net> - 2011-09-01 22:06 +0000
      Re: fflush Kenneth Brody <kenbrody@spamcop.net> - 2011-09-02 11:05 -0400
        Re: fflush Kleuskes & Moos <kleuske@somewhere.else.net> - 2011-09-02 17:04 +0000
  Re: fflush Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2011-09-01 14:55 -0600
  Re: fflush pete <pfiland@mindspring.com> - 2011-09-01 19:14 -0400
    Re: fflush Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2011-09-01 17:27 -0600
      Re: fflush pete <pfiland@mindspring.com> - 2011-09-01 19:33 -0400
      Re: fflush Seebs <usenet-nospam@seebs.net> - 2011-09-02 01:36 +0000
      Re: fflush Kenneth Brody <kenbrody@spamcop.net> - 2011-09-02 11:08 -0400
        Re: fflush Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2011-09-02 09:35 -0600
        Re: fflush Nobody <nobody@nowhere.com> - 2011-09-03 07:24 +0100
      Re: fflush gordonb.47ba6@burditt.org (Gordon Burditt) - 2011-09-02 21:42 -0500
        Re: fflush Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2011-09-02 21:01 -0600
  Re: fflush Nobody <nobody@nowhere.com> - 2011-09-02 00:34 +0100
  Re: fflush mathog <dmathog@gmail.com> - 2011-09-02 09:57 -0700
    Re: fflush David Thompson <dave.thompson2@verizon.net> - 2011-09-09 01:28 -0400
  Re: fflush gordonb.o3gsp@burditt.org (Gordon Burditt) - 2011-09-02 21:36 -0500
    Re: fflush Keith Thompson <kst-u@mib.org> - 2011-09-03 12:05 -0700
      Re: fflush Kenneth Brody <kenbrody@spamcop.net> - 2011-09-06 12:51 -0400
        Re: fflush Keith Thompson <kst-u@mib.org> - 2011-09-06 10:51 -0700
  Re: fflush "io_x" <a@b.c.invalid> - 2011-09-03 10:13 +0200
    Re: fflush "io_x" <a@b.c.invalid> - 2011-09-09 08:19 +0200

csiph-web