title: sizeof char* array in C/C++
body: <p>There are plenty of similar inquires, but in my case I don't understand what isn't working:</p>
  
  <pre><code>int mysize = 0;
  mysize = sizeof(samplestring) / sizeof(*samplestring);
  std::cout &lt;&lt; mysize &lt;&lt; '\n' &lt;&lt; samplestring;
  </code></pre>
  
  <p>This outputs:</p>
  
  <pre><code>4
  
  Press 'q' to quit.
  </code></pre>
  
  <p>How is it possible? 4 definitely isn't the size of this string. I even tried the following, with the same result:</p>
  
  <p><code>mysize = sizeof(samplestring) / sizeof(samplestring[0]);</code></p>
  
  <p>EDIT: Ok, this is the declaration:</p>
  
  <pre><code>char *samplestring = "Start."; 
  </code></pre>
  
  <p>I'm on C++, but I need to use functions that only accept char *. Later in the code I assign new strings to that variable, like:</p>
  
  <pre><code>samplestring = "Press 'r' for red text.";
  </code></pre>
  
  <p>Yes, the compiler gives me warnings, but I have no idea how can I use different strings if I can't overwrite them...</p>