title: string in mmap shared memory c++
body: <p>My program is having segfault.</p>
  
  <p>I'm trying access string from forks, but I can't even put data to shared memory.</p>
  
  <p><strong>My code:</strong></p>
  
  <pre><code>static string * currentSessionIP;
  
  int main(int argc, char *argv[])
  {
      currentSessionIP = static_cast&lt;string*&gt;(mmap(NULL, 4096, PROT_READ | PROT_WRITE,
           MAP_PRIVATE | MAP_ANONYMOUS, -1, 0));
      *currentSessionIP = "";
  }
  </code></pre>
  
  <p>There are no errors when mmap, but when I'm trying to assign something, it's segfaults.</p>
  
  <p>How can I access to string from any fork(), and even change it?<br>
  Thanks in advance!</p>