title: If I use a struct to carry argc and argv, how do I assign the address argv to a variable inside the structure?
body: <p>I have defined some structure above main as:</p>
  
  <pre><code>struct arguments
  {
     int c;
     char *v[];
  };
  </code></pre>
  
  <p>now I want to do this in main:</p>
  
  <pre><code>int main(int argc, char *argv[])
  {
      arguments arg;
  
      arg.c = argc;
      arg.v = argv; /* error: incompatible types in assignment of 'char** to char* [0]' */
  }
  </code></pre>
  
  <p>So, I do not fully understand what I am doing, but instinctively I remade the structure such that the line <code>char *v[];</code> is instead <code>char **v[];</code> however, this means when I pass by reference my structure <code>arg</code>, if I want to dereference and get the value of <code>arg.v[0]</code>, which will be the program name, I now have to do <code>*arg.v[0]</code> and this no longer works for <code>*arg.v[1]</code>.</p>
  
  <p>I have a function such as:</p>
  
  <pre><code>void argument_reader(arguments &amp;arg)
  {
     cout &lt;&lt; "Number of arguments: " &lt;&lt; arg.c &lt;&lt; endl &lt;&lt; endl;
     cout &lt;&lt; "Array\t\tValue\n";
     cout_bar(40);
     for (int i = 0; i &lt; arg.c; i++)
     {
        cout &lt;&lt; "argv[" &lt;&lt; i &lt;&lt; "]\t\t" &lt;&lt; *arg.v[i] &lt;&lt; endl;
     }
     return;
  }
  </code></pre>
  
  <p>but when I call <code>*arg.v[i]</code> the program ends without printing the value of the second argument or any others for that matter.</p>
  
  <p>So my question is,  is there some way I can use the struct to pass between functions such that I can call <code>arg.v[some_index &lt; arg.c]</code> inside another function by somehow making the line <code>arg.v = argv</code> in main work as I had intended (to store the address of <code>argv</code> in <code>arg.v</code>)</p>
  
  <p>All the structure does is make it so that instead of having to pass <code>argc</code> and <code>argv</code> to a function which has a decleration like: <code>void func(int &amp;argc, char *argv[]);</code> I can instead pass my new structure type with variable name <code>arg</code> to a function declared like <code>void func(arguments &amp;arg)</code> and that is basically all I wanted the structure for. So if I cannot do this, then I can go back to the first method.</p>