Hello to all,
I have this code and i want to print the questions.
String question1 ="What's your name?";
String question2 = "What's your surname?";
String question3 = "What'is your age?";
String finalquestion;
String generic="question";void setup() {
Serial.begin(9600);
}void loop() {
for (int x=1; x<4; x++) {
finalquestion=generic+x;
Serial.println(finalquestion);
delay(1000);
}
}
If I run the code I get as a result: "question1"
"question2"
"question3."
That are the names of the variables that i would like to print.
But instead I want to get "What's your name?"
"What's your surname?"
"What'is your age?"
That are the values of the variables that i would like to print.
In this example, the contents of the variable finalquestion is equal to the name of the variable that I would like to print.
I know that Serial.println (finalquestion) prints the value of finalquestion.
But if I wanted to print the value of variables question1, question2, question3 how should I do?
What is the right way to do it?
Thank you.