how to get the value from cmd prompt to c++?

IceCream's Avatar, Join Date: May 2010
Newbie Member
using c++ with command prompt codes... i wanna know how to get the value from cmd prompt to c++?

example i want to get the hostname:

char x;
x=system("FOR /F \"usebackq tokens=1\" %B IN (`hostname`) do echo %B");

something like this...
0
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
Redirect the output to a file, then open the file after the system() command and read it.
Alternatively find out how to do this by using OS calls - that's how the shell does it.