title: sprintf corrupting arrays in IAR microcontroller
body: <p>I am currently learning embedded programming, and thus working on an IAR-platform using a TI microcontroller with ARM architecture. Since I am not at all familiar with the technicalities related to this kind of programming, or C programming in general, I would like to ask a basic question:</p>
  
  <p>I have the following simple code snippet:</p>
  
  <pre><code>int i;
  for(i = 0; i &lt; NUM_SAMPLES; i++)
  {
      sinTable[i] = sinf(2*i*dT*PI);
  }
  
  
  for(i = 0; i &lt; NUM_SAMPLES; i++)
  {
      char out[32];
      sprintf(out,"sin: %.7f, %.7f;", i*dT, sinTable[i]);
      putString(out);
      delay(DELAY_100US);
  }
  </code></pre>
  
  <p>Where <code> sinTable[] </code> is a global variable of size <code>NUM_SAMPLES</code>, <code>putString(*char)</code> is a function which writes to an RS232-port, and <code>delay(float)</code> is a simple delay-function.</p>
  
  <p>My problem is that once the <code>sprintf(...)</code> is called, it corrupts <code>sinTable</code>, giving some very peculiar results when plotting the table on the receiver end of the COM-signal.</p>
  
  <p>I don't expect that I run out of memory, as the MC has 64KB SRAM.</p>
  
  <p>Does anyone have any thoughts?</p>