//wokwi.com/projects/363604810432896001
//Create an array of pointers and initialize 4 different strings. These strings are programmed
// into flash during programming because the 'const' keyword is used to make the pointers point
// to flash memory. Also, create some generic variables used for the loops.
const char *p[4] = {"ALARM", "FAULT", "SENSOR", "UNLOCK"};
const char **pp = &p[0];
char y;
//Function prototype
void string_access(const char **message_pointer);
void setup() {
Serial.begin(115200);
//Step through the following code and watch the 'y' variable. This code will separately access each
// string in the array. This code will pass the pointer address to the strings to the function. It will
// increment the double pointer to point to the next string. This method demonstrates how to pass the
// pointer to the function.
//Access "ALARM"
pp = &p[0];
string_access(&*pp);
//Access "FAULT"
pp++;
string_access(&*pp);
//Access "SENSOR"
pp++;
string_access(&*pp);
//Access "UNLOCK"
pp++;
string_access(&*pp);
}
void loop() {
// put your main code here, to run repeatedly:
}
//This function receives the address of the array pointer to the text strings. The
// double pointer allows us to pass the address of pointers to functions. The function
// will access each character in the string until the NULL character is reached.
void string_access(const char **message_pointer)
{
char i;
i = 0;
do {
y = *(*message_pointer + i);
i++;
Serial.print(y);
} while (y != '\0');
Serial.println();
}