0
How to declare a array of string and how to call it in the cin
Cpp
6 Answers
+ 2
How about writing a simple menu then? You can use an integer to represent the different choices the user has, and you could also choose to put everything inside a loop to let the user enter strings repeatedly until he decides to stop.
It could look like the following (the code is just a bare skeleton example though):
https://code.sololearn.com/cmk076e7ue3B/?ref=app
If you have an array of strings instead of multiple variables, you can use the integer as index to refer to the different strings when acquiring the input.
+ 3
Not sure if this is what you mean, but you can declare an array of strings just like any other array, e.g.
string arr[ 5 ];
And then you can request single strings from the user by referring to the string located at a certain index:
cin >> arr[ 0 ];
+ 1
Ur amazing thx
0
I have 3 strings private and governmental and international and the user should choose the one of them
How can i put in the cin
0
So you want to let the user choose which string to enter?
0
Exactly