-----------------------------------------------------------

New Message on cochindotnet

-----------------------------------------------------------
From: dolly
Message 1 in Discussion

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

-----------------------------------------------------------

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]

Reply via email to