The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to write to stdin of another program (program A -> [stdin]program B) vvaidyan UNIX for Dummies Questions & Answers 3 08-02-2008 02:21 PM
Perform action file name written to the pipe fed.linuxgossip Shell Programming and Scripting 2 07-23-2008 07:38 AM
C++ How to use pipe() & fork() with stdin and stdout to another program vvaidyan High Level Programming 2 05-16-2008 04:30 PM
How to write to stdin of another program (program A -> [stdin]program B) vvaidyan High Level Programming 1 04-30-2008 10:44 AM
AIX 5.3 - There is no process to read data written to a pipe vigsgb UNIX for Advanced & Expert Users 4 06-21-2006 01:09 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #8 (permalink)  
Old 05-14-2008
Registered User
 

Join Date: Jul 2007
Posts: 74
Stumble this Post!
to clear out the left overs in STDIN....,

fflush(STDIN);

this should work. correct me if it is no the one which you are looking for...!!

-ilan
Reply With Quote
Forum Sponsor
  #9 (permalink)  
Old 05-15-2008
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,849
Stumble this Post!
fflush is undefined for reading. If this happens to work, that is great, but you cannot depend on programming by coincidence... Per C standard.

You have to read an input stream or socket to clear it.
Reply With Quote
  #10 (permalink)  
Old 05-15-2008
Registered User
 

Join Date: Mar 2008
Posts: 15
Stumble this Post!
problem solved

There is high potential for me to get beaten up in this forum for what silly mistake i did, which was causing all the problem. But I know several people have looked in through this thread spending significant time in providing me the solution, and this is something I do not take it for granted.

This is what was causing the problem:

int StartPipe(iosockinet &s, char input_to_program_b[])
{
int fd1[2];
int fd2[2];
pid_t pid;
char line[MAXLINE];


I did not initialise the above char array to null;

char line[MAXLINE] = {0}; solved the problem.

Thank you so much guys, I learnt a lot from the information you guys provided me with.
Vivek
Reply With Quote
  #11 (permalink)  
Old 05-15-2008
Registered User
 

Join Date: Jul 2007
Posts: 74
Stumble this Post!
Hi Jim,

just started with looking at threads to get started with programming C :-) now, after reading further on your comment i got to the problems that fflush can do...(ofcourse any functions that have unexpected anomalies)

Thanks!!

-ilan
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 04:36 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0