Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   how to get the value from cmd prompt to c++? (http://www.go4expert.com/forums/value-cmd-prompt-cpp-t22204/)

IceCream 26May2010 14:35

how to get the value from cmd prompt to c++?
 
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"); :freak:

something like this... :)

xpi0t0s 27May2010 12:20

Re: how to get the value from cmd prompt to c++?
 
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.


All times are GMT +5.5. The time now is 23:48.