title: sprintf() function not giving the desired output
body: <p>This is a small portion of code that splits variables into characters, all of the characters are then placed in sequence in a buffer. I have managed to get that part to work but I am having some issues with the sprintf function. The signed integer Cur_Scale is not outputting the correct characters.</p>
  <p>I have tried modifying the formatting specifiers but always get a similar output. The only way I get the correct value is if I place a &quot;-&quot; in front of the argument / the variable.</p>
  <p>I'm sure it's something very easy I'm overlooking but just can not spot it.</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  #include &lt;ctype.h&gt;
  #include &lt;stdint.h&gt;
  
  int32_t Seconds_Timer = 123456789;
  int32_t Cur_Scale = -254123678;
  uint8_t buffer[250];
  uint8_t buffer_2[20];
  
  int main()
  {          
              memset(buffer, 0, sizeof buffer);       // Set all buffer to zero 
              memset(buffer_2, 0, sizeof buffer_2);   // Set all buffer_2 to zero 
              sprintf(buffer_2, &quot;%ld&quot;, Seconds_Timer); // This will put up to 9 characters in buffer
              //Split the variable into characters
              
              uint8_t a;
              uint8_t b;
              
              for(a=0; a&lt;=8; a++) 
                  {
                  buffer[a]=buffer_2[a];
                  }
              
              memset(buffer_2, 0, sizeof buffer_2);   // Set all buffer_2 to zero 
              sprintf(buffer_2, &quot;%ld&quot;, Cur_Scale); // This will put up to 10 characters in buffer
              
              for(a=9,b=0; a&lt;=18; a++,b++)    
                  {
                  buffer[a]=buffer_2[b];
                  }
              printf(buffer, 20);     // Send confirmed value back in characters    
  }
  </code></pre>