title: C++ string to C char array for writing to binary file
body: <p>I am trying to write and read string to/from binary file, but I can't understand why sizeof(t) returns 4.</p>
  
  <pre><code>//write to file
  ofstream f1("example.bin", ios::binary | ios::out);
  string s = "Valentin";
  char* t = new char[s.length()+1];
  strcpy(t, s.c_str());
  cout &lt;&lt; s.length()+1 &lt;&lt; " " &lt;&lt; sizeof(t) &lt;&lt; endl; // prints 9 4
  for(int i = 0; i &lt; sizeof(t); i++)
  {
      //t[i] += 100;
  }
  f1.write(t, sizeof(t));
  f1.close();
  
  // read from file
  ifstream f2("example.bin", ios::binary | ios::in);
  while(f2)
  {
      int8_t x;
      f2.read((char*)&amp;x, 1);
      //x -= 100;
      cout &lt;&lt; x;  //print Valee
  }
  cout &lt;&lt; endl;
  f2.close();
  </code></pre>
  
  <p>It doesn't matter what size I put in char* array t, code always prints "4" as its size. What must I do to write longer than 4 bytes of data?</p>