title: C++ Arduino: adding and getting values from hashmap returns garbage values
body: <p>I've got a small program on my Arduino, in which I use the HashMap lib from Wiring framework. 
  Anyways, the HashMap is of key type char *, and value type char * as well.
  I read some keys and values from a file and I try to add them to the map. I read them as Strings, and then I use the .c_str() method to convert them into char *. 
  When I then print the map, I get very weird values, which I think might be garbage from the memory?
  Anyone knows how can I fix that, and why that happens? I was thinking it might have to do something with the temporary values in the memory returned by .c_str(), but I'm not sure. Any help? 
  Here is the code: (st is just a string and I split it into two, where the : is).</p>
  
  <pre><code>    String msgC = st.substring(0, st.indexOf(":") - 1);
      const char* messageCode = msgC.c_str();
      String msg = st.substring(st.indexOf(":") + 1);
      const char* message = msg.c_str();
      hashMap[messageCode] = message;
  </code></pre>
  
  <p>When I print the 'message' and 'messageCode' into the console, they are fine.
  Output when I print the hashmap: </p>
  
  <p>Key: rently wiping, hig&amp; Value: B0 D8 0 BE A0 9B 86:Wipers currently wiping, hig&amp;
  Key:  Value: ⸮pers currently wiping, high speed.</p>
  
  <p>Key:  Value: ⸮</p>
  
  <p>EDIT:
  When I use String types of the hashMap key and values, I get more strange behavior: </p>
  
  <pre><code>if (dataFile)   { 
    String st;
   while (dataFile.available() &gt; 0) {
    char s = char(dataFile.read());
    if (s!='\n'){
      st = st+s;
    }
    else{
      String msgC = st.substring(0, st.indexOf(":") - 1);
      String msg = st.substring(st.indexOf(":") + 1);
      Serial.print(msgC + " " + msg);
      hashMap[msgC] = msg;
      st = "";
    }
  } 
  </code></pre>
  
  <p>Now the first three pairs of msgC and msg are read and stored fine. But the rest get split mid sentence or are not loaded at all. The output from the Serial.print: <br>
  1D0 834 B0 D8 0 A0 A0 9B 8 Wipers are off. <br>
  1D0 834 B0 D8 0 A8 A0 9B 8 Wipers on, single wipe. <br>
  1D0 834 B0 D8 0 A1 A0 9B 8 Wipers are on, not wiping. <br>
  (Up until here it's ok)</p>
  
  <p>currently wiping, low speed.
   currently wiping, low speed.
  tly wiping, medium speed.
   tly wiping, medium speed.
  urrently wiping, high speed.
   urrently wiping, high speed.</p>
  
  <p>Weird stuff. And this did not happen when I used char * in the HashMap, and I did not change anything else in the code. How come that changing the type of HashMap keys and values could affect this reading from a file? </p>