question list

for a school assignment, I have to make a question list
is there a function to store a string like a integer with int age = Serial.parseInt();

I can’t find anything on the internet about this topic

please help!!!

code:
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}

void loop() {
// put your main code here, to run repeatedly:

//naam
Serial.write (“What’s your name? \n”);
while (Serial.available() == 0) {
}
char firstName = Serial.parse(); // <----------- ?

while (Serial.available() > 0) {
Serial.read();
}

//leeftijd
Serial.write (“how old \n”);

while (Serial.available() == 0) {
}
int age = Serial.parseInt();

while (Serial.available() > 0) {
Serial.read();
}

//print story
Serial.print(firstName);

Serial.print(age, DEC);

delay(50);

I've got the same problem, I can't find anything on the net about saving chars

for starters
Serial basic doc

Juraj:
for starters
Serial basic doc

but how would you write that in my code

I dont get it

code:
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}

void loop() {
// put your main code here, to run repeatedly:

//naam
Serial.write (“What’s your name? \n”);
while (Serial.available() == 0) {
}
char firstName = Serial.parse(); // <----------- ?

while (Serial.available() > 0) {
Serial.read();
}

//leeftijd
Serial.write (“how old \n”);

while (Serial.available() == 0) {
}
int age = Serial.parseInt();

while (Serial.available() > 0) {
Serial.read();
}

//print story
Serial.print(firstName);

Serial.print(age, DEC);

delay(50);

char firstName = Serial.parse(); // <----------- ?

The Serial class does NOT have a parse method. It has a parseInt() method, because it KNOWS what a stream of characters that represent an integer value looks like. It has a parseFloat() method because it KNOWS what a stream of characters that represent a float value looks like.

It also has other methods documented in the Stream page that WILL provide the crutches you are looking for.

The readString() method does NOT return a char, though, so do not expect to store a first name in a char, unless you first name is only one letter. If that is the case, sue your parents.