I have a code written that performs this task to a certain extent. But, I would like to how to alter my code so that I can store as many string inputs the user wants to ente
You need to change your code in order to work for any number of user input.
The logic is to push every sub string between the commas into vector
.
vector objects;
for(int i = 0,j=0; i
In order to print the vector first you have to find the size of the vector,then simply iterate over to print it.
//display
int l=objects.size();
for (int k = 0; k < l; k++) {
cout << objects[k] << endl;
}
Note: If you want your code to work for strings with spaces in between , for example: a ,b ,c ,d
then use getline(cin,input);
to take input from user.