0
How to get multiple names in getli6
getline name of three students https://code.sololearn.com/cUOhyBKQ4lxt/?ref=app
3 Respuestas
+ 1
You could declare 3 char arrays or make the one array longer char array enough to hold the 3 names (amend your getline to reflect this)....It entirely depends on what you plan to do with it/them afterwards and how you want to take the input.
If your gona use a single array and you want to do:-
name1...enter
name2...enter
name3.. enter.
...you can specify a delimiter as a third argument to getline.
+ 1
First of all, use multiple variables to store multiple names. These variables' types should be string or char type array. Then you can use getline function to get multiple names. For example:
string name1;
string naem2;
string name3;
getline(cin, name1, name2, name3);
+ 1
Misbah Ahmed
Did you check your answer before posting? the snippet didn't work when I test ran it.