feasibilty of the memset operation on the FILE streams

V

vin pane

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...>
 
L

Lew Pitcher

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

vin said:
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-----
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top