Currently I convert the characters in char received[20]
to string using String randomString(received)
and I am able to display it using Serial.println(randomString)
. After displaying the string, I would like to know the easiest way to clear out its contents.
|
|||||||||
|
In C and C++ a null terminated array of characters is a string (although not a String). Many routines for reading input terminate the result with a null as does an assignment like"
All you would need to do to "clear" this string is to assign a null to the first character. For example:
|
|||||||||
|
First version with conversion from char[] to Arduino String class:
Second version without the Arduino String class:
And third version where the buffer is cleared:
Cheers! |
|||
|