Re: Quick Question

From: Mike Wahler (mkwahler_at_mkwahler.net)
Date: 02/03/04


Date: Tue, 03 Feb 2004 19:59:03 GMT


"Carter" <cjcastor@phreaker.net> wrote in message
news:b7fc5708.0402031127.4d338b09@posting.google.com...
> How do you make the output of a c++ program be interpreted as a UNIX
> command? Example, what would a program that executed ls look like?

#include <cstdlib>
#include <iostream>

int main()
{
    int status = EXIT_SUCCESS;

    if(system(NULL))
        system("ls");
    else
    {
        std::cerr << "Command processor not available\n";
        status = EXIT_FAILURE;
    }

    return status;
}

-Mike