First make your mind up whether you want to use Strings (uppercase S) which are objects created using the Arduino String library
or
C style strings (lowercase s) which are zero terminated arrays of chars
Using the former in the Arduino environment is usually regarded as a bad idea in the small memory environment of the average Arduino because of the memory fragmentation they cause. I note, however, that Strings are used extensively in programs for the ESP8266 and ESP32 but they do have more memory than the AVR based boards
From the little information that you have posted it seems that your are trying to parse a String using functions designed to work with strings
Please post a complete sketch and the associated error messages
This looks an attempt to remove unwanted incoming characters from the Rx buffer after the B has been found. However, what Serial.flush() does is to wait until all characters in the Tx buffer have been sent. If you want to remove characters from the Rx buffer then you need to read and discard them until no more are available
This looks an attempt to remove unwanted incoming characters from the Rx buffer after the B has been found. However, what Serial.flush() does is to wait until all characters in the Tx buffer have been sent. If you want to remove characters from the Rx buffer then you need to read and discard them until no more are available