Nur mal so als Anregung... Aus meinem eigenen Code...
Code:
if(getBufferLength()) 
    {
        char tmp = readChar(); 
        if (tmp =='#') 
        {
            mSleep(10); 
            counter = 0; 
        }
        text[counter] = tmp; 
        text[counter + 1] = '\0';
        counter++;
    }
    int cmd = getCommand();     
    if(cmd)
    {     
          [..]
    }