Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Executing a command in C program & Redirecting output to String array 1

Status
Not open for further replies.

gvidos

Programmer
Jul 24, 2002
17
0
0
GR
Hi,

I have a C program that invokes the system function every 1 sec (for sampling reasons) and I need to parse the output as shown in stdout,by storing this output to a char array.What I first imagined to be the solution was:

system("tunnel -L -c");
fscanf(stdout,"%s",buffer);

but when control has reached fscanf,the system function has already been completed,having displayed already the output.

How can I possibly capture that output (without re-directing it to a file)?

Thank you,

George
 
Code:
man popen

or do a keyword search for popen on this site.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top