In article <11************ **********@z34g 2000cwc.googleg roups.com>,
SF <so***********@ gmail.com> wrote:
In a windows C learning project I am wokring on I use the system
function to run a command, I want to suck the results into a vairable.
The system function seems to only return an int. I would like to know
how could this is done?
There is no way to do it using only standard C.
I can see only one way currently and I know
that there must be a better method. Right now I would be tempted to
pipe the output of the command to a temp file and then get the data
from the file. That seems really dirty to me, can you suggest a better
way?
pipes are operating system-specific extensions, outside the
control of standard C. Standard C does not even define the result
of using system(): it just says that it exists and that the result
is operating-system dependant.
Possibly you meant "redirect" instead of "pipe", but the ability to
redirect system() output into a file is again operating-system dependant
(though it's probably available on more operating systems than support
pipes.)
For what it's worth, the usual POSIX of handling this is to use
popen(), but if you want to know what facilities are available in
Windows, you should check a Windows programming newsgroup.
--
I was very young in those days, but I was also rather dim.
-- Christopher Priest