title: Parse serial port data
body: <p>I am using C, which reads the data on the serial port ok. But as with serial port the data is not always the same length. I would like to read up until <code>\n\r</code>. The buffer <code>char szBuff[10]</code> which is declared at the top of the program contains the data from the serial port from the <code>Readfile()</code> method.</p>
  
  <p>I was going to put a <code>(while != "\n")</code> to fill up a temporary buffer but will not work. I have also tried to print out individual elements of of <code>szBuff</code> to see whats happening) but that crashes the program.</p>
  
  <pre><code>    void ReadSerialPort (void){
  
        strcpy(szBuff, "");
        dwBytesRead = 0;
        char temp;
  
        //printf("Reading Port %s...", portName);
        if(!ReadFile(hSerial, szBuff, bufSize, &amp;dwBytesRead, NULL)){
        // Error occurred. Inform user
         printf("Error occurred during read\n");
        }
  
  
        if((int) dwBytesRead == 0)
         printf("0 Characters Read\n");
        else
         //printf("Read String: %s, Number of Characters: %d\n\n", szBuff, (int) dwBytesRead);
        // printf("%s ", szBuff, (int) dwBytesRead);
  
        while(szBuff != "\n")
          fill buffer
  
          temp = szBuff[1];
           printf( szBuff);
           printf( temp);
  }
  </code></pre>
  
  <p>Why cant the individual elements be printed out and why cant the while search through for <code>\n</code> or is there a better way to accomplish this?</p>