By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,187 Members | 1,038 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,187 IT Pros & Developers. It's quick & easy.

feasibilty of the memset operation on the FILE streams

P: n/a
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...>
Nov 14 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
-----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+agVFX4UWr64RAub0AJ0aepkeuG1rbAf5xpcGNE Af59CR/ACgzXbw
uvVzOK9QdKhNDQj0GbPCAec=
=jdX4
-----END PGP SIGNATURE-----
Nov 14 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.