title: Char has a different size than a string
body: <p>I was working with a program that uses a function to set a new value in the registry, I used a <code>const char *</code> to get the value. However, the size of the value is only four bytes. I've tried to use <code>std::string</code> as a parameter instead, it didn't work.<br>
  I have a small example to show you what I'm talking about, and rather than solving my problem with the function I'd like to know the reason it does this.</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  
  void test(const char * input)
  {
      std::cout &lt;&lt; input;
      std::cout &lt;&lt; "\n" &lt;&lt; sizeof("THIS IS A TEST") &lt;&lt; "\n" &lt;&lt; sizeof(input) &lt;&lt; "\n";
      /* The code above prints out the  size of an explicit string (THIS IS A TEST), which is 15. */
      /* It then prints out the size of input, which is 4.*/
  
      int sum = 0;
      for(int i = 0; i &lt; 15; i++) //Printed out each character, added the size of each to sum and printed it out.
      //The result was 15.
      {
          sum += sizeof(input[i]);
          std::cout &lt;&lt; input[i];
      }
      std::cout &lt;&lt; "\n" &lt;&lt; sum;
  }
  int main(int argc, char * argv[])
  {
      test("THIS IS A TEST");
      std::cin.get();
      return 0;
  }
  
  Output:
  THIS IS A TEST
  15
  4
  THIS IS A TEST
  15
  </code></pre>
  
  <p>What's the correct way to get string parameters? Do I have to loop through the whole array of characters and print each to a string (the value in the registry was only the first four bytes of the char)? Or can I use <code>std::string</code> as a parameter instead?<br>
  I wasn't sure if this was SO material, but I decided to post here as I consider this to be one of my best sources for programming related information.</p>