Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > feasibilty of the memset operation on the FILE streams

Reply
Thread Tools

feasibilty of the memset operation on the FILE streams

 
 
vin pane
Guest
Posts: n/a
 
      01-28-2005
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...>
 
Reply With Quote
 
 
 
 
Lew Pitcher
Guest
Posts: n/a
 
      01-28-2005
-----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-----
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Boolean operation and arithmetic operation Buzz Lightyear C++ 10 08-12-2009 01:27 PM
The close() operation for streams Stefan Ram Java 19 06-14-2008 02:50 PM
I/O operation, file operation behaviou raan C++ 2 08-16-2007 07:13 PM
Does bit operation always work more efficiently than math operation? david ullua C Programming 13 03-01-2006 11:02 PM
mixing C FILE* and C++ file streams ?? Marc Cromme C++ 1 12-02-2003 01:56 AM



Advertisments