I am trying something like this:
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;
int main()
{
string inputStr;
vector <string> strVector;
cin.getline(inputStr,200);
int i=0;
while (inputStr!=NULL){ //unless all data is read.
strVector[i]=getline(inputStr," ");
i++;
}//while.
for (int j=0; j<strVector.size(); j++){
cout<< strVector[j];
cout<<endl;
}
} //main.
Any one who can help. I am trying to store my input string in vector string and then I can push_back my ith string.
push_backmethod:strVector.push_back(getline(inputStr, " "));getline(inputStr," ")doing? If you're looking to simply load a vector with whitespace-seperated strings fromcinthere are simpler ways to do this.