I have a problem regarding displaying name of the user | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

I have a problem regarding displaying name of the user

It gets an error on the cout I wanted to accept only 5 names only from the user input and display it. https://code.sololearn.com/c3sG9f4tKw2s/?ref=app

14th Nov 2023, 7:25 AM
shlee_
shlee_ - avatar
5 Answers
+ 5
shlee_ Print like this for(int i=0; i<5; i++){ if (arr[i] != "") cout<<"\nHere are the names: "<< arr[i]; }
14th Nov 2023, 9:39 AM
A͢J
A͢J - avatar
+ 4
shlee_ name++; should be outside the else part to avoid Execution timeout. And you should print arr instead of NameEntered, this will print only last entered name.
14th Nov 2023, 9:31 AM
A͢J
A͢J - avatar
+ 2
line 51: you have only 1 of "<", try to use 2 of them, like earlier
14th Nov 2023, 8:32 AM
Mihaly Nyilas
Mihaly Nyilas - avatar
+ 2
Thank you A͢J
14th Nov 2023, 9:46 AM
shlee_
shlee_ - avatar
0
A͢J still shows only last name entered
14th Nov 2023, 9:38 AM
shlee_
shlee_ - avatar