
#define CR 0x0D
#define MAXSTRLEN 10 // Max string length expected

char tempstr[MAXSTRLEN];
char ch;

tempstr[0] = '/0';
i = 0;
while( (ch = getch()) != CR)
{
   tempstr[i++] = ch;
   tempstr[i] = '/0'   // add new char to string
   if (valid_command(tempstr) break;
}
