Terminal Commands

Hi There,
I have to write a program which takes "ls" command (that displays the list of files in linux) as a command line argument..
I don't have any idea .. how to execute that.. Please Help Me.. Stuck at the following program
Thanks In Advance :)
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>
#include <unistd.h>
using namespace std;
int main (int argc, char *argv[])
{
    int ret;
    cout<<"Displaying the list of files using ls as a command line argument\n";
    // I don't know what to do here
    ret= execl("/usr/bin/argv","list of files,o",NULL);
    if (ret == -1 )
        cout<<"failed\n";
    return 0;
}
Duplicate post. Please don't do that.
http://www.cplusplus.com/forum/general/175854/
Topic archived. No new replies allowed.