title: How to send integer as a string with WriteFile for serialport
body: <p>I want to send an integer as a string buffer to a serial port with <code>WriteFile</code>. This data value is result from the sensor, this data max has 2 characters. </p>
  
  <p>I have tried to convert with itoa</p>
  
  <p>for example:</p>
  
  <pre><code> DWORD nbytes;
   int a,b,c;
   a=10;
  char *tempa ="";
  tempa = itoa(a, tempa,0);
  if(!WriteFile( hnd_serial, a, 2, &amp;nbytes, NULL )){MessageBox(L"Write Com Port fail!");return;} 
  </code></pre>
  
  <p>This code is not working. </p>
  
  <pre><code>Unhandled exception at 0x1024d496 (msvcr100d.dll) in ENVSConfig.exe: 0xC0000094: Integer division by zero.
  </code></pre>
  
  <p>Also I have tried the suggestion from this website:
  <a href="http://notfaq.wordpress.com/2006/08/30/c-convert-int-to-string/" rel="nofollow">convert int to string</a> but still does not working to. </p>
  
  <p>Is there any clue to do this?</p>