-----------------------------------------------------------
New Message on cochindotnet
-----------------------------------------------------------
From: J.K.
Message 2 in Discussion
Pooja,
Use GetFileType(GetStdHandle(STD_INPUT_HANDLE)) to determine if the
handle belongs to a file, device or pipe...
Have a nice day,
Jayakrishnan K.
<x-tab> </x-tab>
At 12:18 AM 7/10/03 -0700, you wrote:
New Message on
cochindotnet
reading stdin C++ (pipe)
Reply
Reply to Sender Recommend Message 1 in Discussion
From: dolly
Hi ,
I have a program to which I want to be able to pipe to if required.
1)at the command prompt when i say dir|myprog.exe , my program must read the stdin to
get output of dir.
2)if I say myprog.exe , my program should continue execution without waiting for any
input.
I tried
if(!cin.eof())
{
gets(buf);
cout<<"\nStdin = "<<stdin;
cout<<"\nCount="<<stdin->_cnt;
cout<<"\nstdin->_ptr = "<<stdin->_ptr;
}
But this waits for an input because of the gets, so 1 works 2 doesn't
So I tried
char buf[4000];
DWORD bytesRead;
HANDLE h = GetStdHandle(STD_INPUT_HANDLE);
if(ReadFile(h,&buf,4000,&bytesRead,NULL)==0)
cout<<"\nError Reading stdin"<<GetLastError();
cout<<"\nstdin->_ptr = "<<stdin->_ptr;
ReadFile here is also a blocking function, hence 2 wont work.
How can I check for data in stdin without blocking the process, ie if there is data I
proceed with it , else without it
Thanks,
Dolly
View other groups in this category.
Also on MSN:
Start Chatting | Listen to Music | House & Home | Try Online Dating | Daily Horoscopes
To stop getting this e-mail, or change how often it arrives, go to your E-mail
Settings.
Need help? If you've forgotten your password, please go to Passport Member Services.
For other questions or feedback, go to our Contact Us page.
If you do not want to receive future e-mail from this MSN group, or if you received
this message by mistake, please click the "Remove" link below. On the pre-addressed
e-mail message that opens, simply click "Send". Your e-mail address will be deleted
from this group's mailing list.
Remove my e-mail address from cochindotnet.
-----------------------------------------------------------
To stop getting this e-mail, or change how often it arrives, go to your E-mail
Settings.
http://groups.msn.com/cochindotnet/_emailsettings.msnw
Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help
For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact
If you do not want to receive future e-mail from this MSN group, or if you received
this message by mistake, please click the "Remove" link below. On the pre-addressed
e-mail message that opens, simply click "Send". Your e-mail address will be deleted
from this group's mailing list.
mailto:[EMAIL PROTECTED]