title: STM32 C : atoi converts part of string which is not an argument
body: <p>I have parsed some date and time from GPS receiver. And need to convert them from string to <code>int</code>:</p>
  
  <pre><code>char year[4] = "2014";
  char month[2] = "01";
  char day[2] = "24";
  char hour[2] ="12";
  char minute[2] = "58";
  char second[2] = "39";
  
  GPS_current_year = atoi(year);
  GPS_current_month = atoi(month);
  GPS_current_day = atoi(day);
  GPS_current_hour = atoi(hour);
  GPS_current_minute = atoi(minute);
  GPS_current_second = atoi(second);
  </code></pre>
  
  <p>After executing these the results are:</p>
  
  <p><img src="https://i.stack.imgur.com/MEExw.png" alt="enter image description here"></p>
  
  <p>Somehow part of minutes string is converted when converting hour string. Same with minutes and seconds.</p>
  
  <p>The strings are placed side by side in the memory.</p>
  
  <p>If I change the sequence of defining strings then seconds may be added to years etc.</p>
  
  <p>Questions:  </p>
  
  <ul>
  <li>What may cause this error?  </li>
  <li>Is there any way to avoid this error with using <code>atoi</code>?</li>
  </ul>
  
  <p>I know that I can convert using a loop one <code>char</code> at a time. Just trying to find why is it not working.</p>