How to copy **argv to a new variable?
<p>I want to make a copy of a variable such as <code>char **argv</code> using something like memcpy but how? can I know the size and how to parameterize it since <code>memcpy</code> doesn't take a two-star as a parameter. Do I have to write a loop?</p>

<p>I have to build up the pipeline before I execute it. Therefore I want to "spawn" variables like <code>argv</code> in every iteration of the loop. </p>

<pre><code>    token = strtok(cmd, "|");
    i = 0;
    while (token != NULL)
    {   
        printf("token %s\n", token);       
        makeArgs(token, &amp;argc, &amp;argv);
        for (int b = 0; b &lt; argc; b++) {
           printf("makeargs %d: %s\n", b, argv[b]);   
        }   

        // Will copy argc characters from array1 to array2
       /* memcpy(makearg,argc, argc*18*sizeof(int));*/    
        shellcommand[i].argv = argv;
        i++;
        token = strtok(NULL, "|");
    }           
   /* do stuff */
   fork_pipes(argc, shellcommand);
</code></pre>

<p>My aim is to build up the pipeline like the following.</p>

<pre><code>/*  who | awk '{print $1}' | sort | uniq -c | sort -n */
static char *cmd0[] = { "who",                0 };
static char *cmd1[] = { "awk",  "{print $1}", 0 };
static char *cmd2[] = { "sort",               0 };
static char *cmd3[] = { "uniq", "-c",         0 };
static char *cmd4[] = { "sort", "-n",         0 };

static char **cmds[] = { cmd0, cmd1, cmd2, cmd3, cmd4 };
</code></pre>