Hi, I'm trying to use command line stuff with C++. I've read that you do it with System(); Is that the best way?

My main question however, is how do you read in the results from the command? I think I can do 'thecommand > file' to output the results to a file, and then read from the file with C++, but I want to know if there is a easier way I can get the results directly without going through that middle file.


9 Years
Discussion Span
Last Post by iamthwee

What do you mean by "command line stuff"? This is very vague. System() can be used to control your program, yes, using commands like "PAUSE" and "CLS," however I would suggest using something like cin.get() or cin.ignore() over System("PAUSE").

Be more specific please.


you can use popen to create a pipe between your program and the other executable. Output of that other program will can be read by your program via the pipe.


oops, you're right. lowercase.

Sorry for being vauge. By "command line stuff" i mean, "command line commands", but I since you have been able to learn a (possibly multiple) programming language, then you would understand what I meant.

My question obviously wasn't about pause or cls though, because I asked about how I can read in the output from the command (e.g. from netstat) . Since pause and cls don't give any output, I wasn't talking about them.


Thank you, I will try that out.

edit: eh, sorry for double posting. Is there no way to delete posts on this forum?


Hi,i want to know the idea for developing a command prompt based line editor. so using this utility & its predefined command user will be able to open,delete,close,swap lines in the file.

Votes + Comments
Start your own thread, don't bump an old one
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.