title: "cannot collect variable"?
body: <p>What does it mean: "Cannot collect variables" ? How can I fix it ? It makes the debugger won't report values. </p>
  
  <p><a href="https://i.stack.imgur.com/YMzCc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YMzCc.png" alt="enter image description here"></a></p>
  
  <p>I'm trying to call my function </p>
  
  <p><code>write_argument2(argc,  * argv, * string[0]);</code></p>
  
  <p>I'm going to change and rearrange <code>argv</code>. My variable <code>string</code> is <code>char **string[100][100];</code> and maybe that is not ideal. The string variable is going to update <code>argv</code> with new arguments:</p>
  
  <pre><code>void write_argument2(int argc, char argv[], char *string[]) {
      int j = 0;
      for (j = 0; j &lt;  argc; j++) {
          if (argv[j])
               string[j] = strdup(&amp;argv[j]);
      }
  }
  </code></pre>
  
  <p>But I've done something wrong and it crashes. The error says "cannot collect variable" and a segmentaion fault for <code>strdup</code>. </p>
  
  <p>I also tried the following which compiles but also becomes a segmentation fault: <code>* string[j] = * strdup( &amp; argv[j]);</code></p>
  
  <p>Gdb says:</p>
  
  <pre><code>GNU gdb (Ubuntu 7.11-0ubuntu1) 7.11
  Copyright (C) 2016 Free Software Foundation, Inc.
  License GPLv3+: GNU GPL version 3 or later &lt;http://gnu.org/licenses/gpl.html&gt;
  This is free software: you are free to change and redistribute it.
  There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
  and "show warranty" for details.
  This GDB was configured as "x86_64-linux-gnu".
  Type "show configuration" for configuration details.
  For bug reporting instructions, please see:
  &lt;http://www.gnu.org/software/gdb/bugs/&gt;.
  Find the GDB manual and other documentation resources online at:
  &lt;http://www.gnu.org/software/gdb/documentation/&gt;.
  For help, type "help".
  Type "apropos word" to search for commands related to "word"...
  Reading symbols from ./shell...done.
  (gdb) run
  Starting program: /home/dac/ClionProjects/shell2/openshell/shell 
  'PATH' is set to /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin.
  $ ls
  
  Program received signal SIGSEGV, Segmentation fault.
  0x0000000000403b1a in write_argument2 (string=&lt;optimized out&gt;, argv=&lt;optimized out&gt;, 
      argc=&lt;optimized out&gt;) at main.c:147
  147              string[j] = strdup( &amp;argv[j]);
  (gdb) 
  </code></pre>
  
  <p>Should I use <code>strcpy</code> instead or change some declarations?</p>