How can I simplify this simple code? (Again...)

guix:
For non blocking Serial reads you can do something like that:

void loop()

{
 if ( Serial.available() > 0 )
 {
   static char input[64];
   static uint8_t i;
   char c = Serial.read();

if ( c != '#' && i < 63)
     input[i++] = c;
   
   else
   {
     input[i] = '\0';
     i = 0;

//process the input string here
     Serial.println( input );
   }
 }
}

Note that I will be read and can be incremented before being initialized with this code.