title: String to const char conversion using c_str() or toCharArray()?
body: <p>I want to know more about programming and after a bit of googling I found how to convert a string to a const char.</p>
  
  <pre><code>String text1;
  </code></pre>
  
  <p>What I do not understand is why c_str() works, </p>
  
  <pre><code>const char *text2 = text1.c_str();
  </code></pre>
  
  <p>contrary to toCharArray()?</p>
  
  <pre><code>const char *text2 = text1.toCharArray();
  </code></pre>
  
  <p>or</p>
  
  <pre><code>const char text2 = text1.toCharArray();
  </code></pre>
  
  <p>The latter is more logical to me as I want to convert a  string to a char, and then turn it into a const char. But that doesn't work because one is a string, the other is a char. The former, as I understand, converts the string to a C-type string and then turns it into a const char. Here, the string suddenly isn't an issue anymore oO</p>
  
  <p>.</p>
  
  <p>a) Why does it need a C-type string conversion and why does it work only then?</p>
  
  <p>b) Why is the pointer needed?</p>
  
  <p>c) Why does a simple toCharArray() not work?</p>
  
  <p>.</p>
  
  <p>Or do I do something terribly wrong?</p>
  
  <p>Thanks heaps.</p>
  
  <p>I am using PlatformIO with Arduino platform.</p>