feasibilty of the memset operation on the FILE streams

Discussion in 'C Programming' started by vin pane, Jan 28, 2005.

  1. vin pane

    vin pane Guest

    your code will not work to flush the previous contents.
    okey I want three line code.

    main()
    {
    getchar();
    sleep();

    eat_stdin(); // flush_stdin --- some code here to remove what user is
    going to //press between this delay of 5 secs .including
    enter key. she may press anything.

    getchar(); // this last getchar should work as we have given a call
    to some //keyboard flushing function .
    }

    My questions is whether a stdin in Linux Line buffered IO or
    Unbuffered IO ? If it is some kind of buffering IO, I must able to
    write that buffer . I mean to say that the code for memset operations
    is the most promissing solution I found. It works what my requirement
    is. since memset performs operation on the void pointer why not FILE *
    stream ? ultimatly think about the buffering part !

    I have found many solutions like setting the mode of the tty to raw &
    then start readin , perform select call for SDTIN_FILENO ... I have
    done many thing.
    I wrote a code of 200 lines just to eat up the stdin !! In cases works
    too.

    -bye


    < Dont want to make any special comment in the EOM like other do...>
    vin pane, Jan 28, 2005
    #1
    1. Advertising

  2. vin pane

    Lew Pitcher Guest

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    vin pane wrote:
    > your code will not work to flush the previous contents.
    > okey I want three line code.

    [code snipped]

    I won't comment on the code. You'll get enough comments from the others
    here.

    > My questions is whether a stdin in Linux Line buffered IO or
    > Unbuffered IO ?


    Yes, stdin in linux is linebuffered or unbuffered.
    Exactly which way the buffering is handled depends on the operational
    environment and is not answerable here. You'll have to ask a Linux
    newsgroup for the exact details.

    > If it is some kind of buffering IO, I must able to
    > write that buffer .


    That, of course, would be the exact wrong thing to do. First off, you
    don't know where in the FILE * to write to, and secondly, there are
    better, cleaner ways to do what you want to do.

    > I mean to say that the code for memset operations
    > is the most promissing solution I found. It works what my requirement
    > is. since memset performs operation on the void pointer why not FILE *
    > stream ? ultimatly think about the buffering part !
    >
    > I have found many solutions like setting the mode of the tty to raw &
    > then start readin , perform select call for SDTIN_FILENO ... I have
    > done many thing.


    Most of those things will be off-topic here.

    > I wrote a code of 200 lines just to eat up the stdin !! In cases works
    > too.


    That's way too much code for this problem. You /really/ need to talk to
    the folk in comp.os.linux.development.apps


    - --

    Lew Pitcher, IT Consultant, Enterprise Data Systems
    Enterprise Technology Solutions, TD Bank Financial Group

    (Opinions expressed here are my own, not my employer's)
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.2.4 (MingW32)

    iD8DBQFB+mU+agVFX4UWr64RAub0AJ0aepkeuG1rbAf5xpcGNEAf59CR/ACgzXbw
    uvVzOK9QdKhNDQj0GbPCAec=
    =jdX4
    -----END PGP SIGNATURE-----
    Lew Pitcher, Jan 28, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marc Cromme
    Replies:
    1
    Views:
    2,540
    Jorge L Rivera
    Dec 2, 2003
  2. david ullua
    Replies:
    13
    Views:
    640
  3. raan
    Replies:
    2
    Views:
    435
  4. Stefan Ram

    The close() operation for streams

    Stefan Ram, Jun 13, 2008, in forum: Java
    Replies:
    19
    Views:
    1,226
  5. Buzz Lightyear
    Replies:
    10
    Views:
    1,101
    Alexander Bartolich
    Aug 12, 2009
Loading...

Share This Page