title: Undefined behavior with 2d array of struct C
body: <p>I have a 2d array of structs that I am assigning strings to, here is my struct. </p>
  
  <pre><code>struct node {
    char* value;
  };
  </code></pre>
  
  <p>Here is my allocation (I am new to C so I am not sure if it is right) but there will always be 35 columns but there could be millions of rows.( I just had it at 3 for now for testing)</p>
  
  <pre><code>const int rows=3;
      struct node ** arrayofnodes[rows][35];
  for(int i=0; i&lt;rows; i++) {
      array[i] = malloc(test * sizeof array[0]);
      for(int j=0; j&lt;35; j++) array[i][j] = malloc(sizeof array[0][0]);
  }
  </code></pre>
  
  <p>I then read in character by character from a csv file and have a temp string, and assign the value of the temp to the position I want by using this below.</p>
  
  <pre><code>//int row and count are defined in my while loop I have for counting commas(or what col I am on) then new lines for the rows 
  arrayofnodes[row][count]-&gt;value=strdup(temp);
     printf("%s  \n", arrayofnodes[row][count]-&gt;value);
     printf("%d %d \n",row, count );
  </code></pre>
  
  <p>When I assign like the way above it seems to work. I added these print statements in to make sure it was assigning the right values. </p>
  
  <p>For example above would print out something like </p>
  
  <blockquote>
  <pre><code>Red
  0 0
  </code></pre>
  </blockquote>
  
  <p>And this is correct for that position. </p>
  
  <p>But then after I do all of my assigning. I placed a print statement <code>printf("%s  \n", arrayofnodes[0][0]-&gt;value);</code> to test if I can retrieve the 1st value as shown above which should be "Red". </p>
  
  <p>In my terminal it outputs "@`??"  or "@Pz?" or just any random output. I have tried this for a bunch of different positions besides 0,0, but they all get the same outcome. I guess I am just confused why the print statements work right after I assign them, but not at the end of my code when I call them later.</p>