Re: is cin always the keyboard's input?
From: Bob Smith (bobsmith_at_jippii.fi)
Date: 10/15/03
- Next message: Alf P. Steinbach: "Re: new"
- Previous message: Alexander Terekhov: "Re: new"
- In reply to: stephan beal: "Re: is cin always the keyboard's input?"
- Next in thread: stephan beal: "Re: is cin always the keyboard's input?"
- Reply: stephan beal: "Re: is cin always the keyboard's input?"
- Reply: tom_usenet: "Re: is cin always the keyboard's input?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 15 Oct 2003 16:18:53 +0300
stephan beal wrote:
> Bob Smith wrote:
>
>
>>question in subject.
>>does the standard say anything about this or is it platform dependent?
>>any advice much appeciated
>>
>
> Indeed, the whole point of 'cin' is to keep this detail hidden from you. It
> is not only platform-dependent, but case-dependent.
> e.g., when you do any of the following:
>
> cat file | myapp
> myapp < file
>
> these are instructing the system to use the file (more specifically, the
> input stream) as cin.
>
>
> See section 15.17 in:
> http://www.parashift.com/c++-faq-lite/input-output.html
well here is my problem:
m_reading is a bool value, qDebug(...) is a qt function, qxevent is a
class which can red from streams.
<snip>
if ( !m_reading ){
if ( std::cin.rdbuf()->in_avail() ){
m_reading = true;
qDebug( "reading...");
QxEvent e;
while( cin >> e ) {
m_event_queue.push( e );
counter++;
}
qDebug( "...read!");
m_reading = false;
}else{
qDebug("..no data" );
}
}else{
qDebug("already reading, return to caller");
}
qDebug("ready");
</snip>
Now, trying to output data from one program, to this program, like
./testdatamaker|./eventlogger
( testdatamaker is a program for making up testdata for eventlogger )
testdatamaker outputs strings every second, and eventlogger polls the
cin stream continuously, but it never receives any data, it always
returns with "no data".
So the whole idea with my application is that it should read the input
stream, that being any output from any program, piped, and make display
data out of it.
I feel silly to ask but what is going wrong ?*s*
any help *very* much appreciated.
thank's
/B
- Next message: Alf P. Steinbach: "Re: new"
- Previous message: Alexander Terekhov: "Re: new"
- In reply to: stephan beal: "Re: is cin always the keyboard's input?"
- Next in thread: stephan beal: "Re: is cin always the keyboard's input?"
- Reply: stephan beal: "Re: is cin always the keyboard's input?"
- Reply: tom_usenet: "Re: is cin always the keyboard's input?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|