title: Pointers inside shared memory segment
body: <p>I've been trying this for hours, and google all the things I kind think of, but I'm going crazy.</p>
  
  <p>I have a struct:</p>
  
  <pre><code>typedef struct {
    int rows;
    int collumns;
    int* mat;
    char* IDs_row;
  } mem;
  </code></pre>
  
  <p>I don't know the sizes of the int* (a Matrix) and char* untill later.</p>
  
  <p>When I do, I create the shared memory like this:</p>
  
  <pre><code>mem *ctrl;
  int size = (2 + ((i-1)*num_cons))*sizeof(int) + i*26*sizeof(char); //I have the real size now
  shmemid = shmget(KEY, size, IPC_CREAT | 0666);
  if (shmemid &lt; 0) {
      perror("Ha fallado la creacion de la memoria compartida.");
      exit(1);
  }
  ctrl = (mem *)shmat(shmemid, 0, 0);
  if (ctrl &lt;= (mem *)(0)) {
      perror("Ha fallado el acceso a memoria compartida");
      exit(2);
  }
  </code></pre>
  
  <p>No problem here. Then I give a value to ctrl->rows and collumns, and assign 0 to all the matrix.</p>
  
  <p>But after that, I write something in the char* and bam, segmentation fault.</p>
  
  <p>Debugging the program I saw that both pointers, mat and IDs_row where null. How do I give them the correct values inside the shared memory segment??</p>
  
  <p>I tried removing the char* pointer, just to give it a try, and then the segmentation fault error was in the other program that connected to said shared memory and just checked the values inside the matrix (checking ->rows and ->collumns was succesfull)</p>