I want to know how to split a variable up into it's individual parts.
The variable can be between 4 and 6 characters long, and is alphanumeric.
e.g.
void processData()
{
char pass = "12345A";
<some code here to determine length of string>
<length = "number of characters"; >
<for loop? to iterate through each character (using length variable) and send to function printpass() >
}
void printpass()
{
Serial.println(character);
}
That link takes you to a page about Strings (objects created using the String library). lesept used strings (arrays of chars terminated by a zero)
The former are not well regarded in the small memory footprint of the average Arduino and should be used with caution, if at all, whilst the latter are not memory hogs and are preferred
So I of course need convert it to a character array. I could use for example "pass.toCharArray(button, 10)”
but it seems to need the array length setting, which I don't want.
Maybe I could use something like:
// assigning value to string s
string s = "geeksforgeeks";
int n = s.length();
// declaring character array
char char_array[n + 1];
// copying the contents of the
// string to char array
strcpy(char_array, s.c_str());