title: How to store chars read from serial port into buffer for processing?
body: <p>Right now I have some code that is printing out data read from a serial port with <code>putch(out)</code>.  But I need to store it into an array and process it to get floating point values out.</p>
  
  <p>Here is my code just for talking to the serial port, with the calculations omitted:</p>
  
  <pre><code>#include &lt;bios.h&gt;
  #include &lt;conio.h&gt;
  
  #define COM1       0
  #define DATA_READY 0x100
  
  // set the baud rate, parity bit, data width...
  #define SETTINGS ( 0xE0 | 0x03 | 0x00 | 0x00)
  
  int main(void)
  {
      int in, out, status,i;
      char dataRead[21];
      float roll, pitch;
      bioscom(0, SETTINGS, COM1); /*initialize the port*/
      clrscr();
      cprintf("Data sent to you:  ");    
  
      while (1) 
      { 
          status = bioscom(3, 0, COM1); // reading the data here
          if (status &amp; DATA_READY)
              if ((out = bioscom(2, 0, COM1) &amp; 0 7F) != 0) 
                  putch(out);                // printing read value
  
          if (kbhit( ))    // If Esc is hit. it breaks and exit.
          { 
              if ((in = getch( )) == ‘ 1B’)   //  1B = Esc
              DONE = TRUE; 
              bioscom(1, in, COM1);  // data write. I am not making use of it.
          } 
      }
      return 0; 
  }   
  </code></pre>
  
  <p>The incoming data encodes the roll and pitch, as something like <code>"R:+XXX.XX P:-YYY.YY\r\n"</code>.  </p>
  
  <p>Instead of just printing this data out, I want to store it in the <code>dataRead[]</code> array and interpret it into float values.  For instance, <code>dataRead[2]</code> to <code>dataRead[8]</code> encodes a float value for the "roll" as characters <code>+XXX.XX</code>.</p>
  
  <p>How do I store these characters in the array and get the floating point number from it?</p>
  
  <p>If you could write down some code for serial port which does exactly what i want then it would be really helpful. Please make sure it is written in 'C'.</p>