0

How to get multiple names in getli6

getline name of three students https://code.sololearn.com/cUOhyBKQ4lxt/?ref=app

22nd Nov 2020, 10:46 AM
Anas kayani
Anas kayani - avatar
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.
22nd Nov 2020, 11:11 AM
rodwynnejones
rodwynnejones - avatar
+ 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);
22nd Nov 2020, 11:15 AM
Misbah Ahmed
Misbah Ahmed - avatar
+ 1
Misbah Ahmed Did you check your answer before posting? the snippet didn't work when I test ran it.
22nd Nov 2020, 3:16 PM
Ipang