ok, so i want a program that just says back to the user their input. the users input will be more then one word, so there will be whitespace. when i use string as a class for the input, then it only gives back the FIRST word of the input....
so i decided to use a vector, but i suck at them...
this is what i tried.. but on line 10, idk what to do :/ thnx!

#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
        vector<string> s;
        string v;
        cin >> v;
        s.push_back(v);
        cout << endl << ????????; //all i want is to read all of the elements inside the vector, idk how....
}

google "getline"

As suggested, a simple getline would get a line. Here is an example :

std::string input;
getline(cin,input);
//now input contains everything the user entered

ok. wud i do "getline(v, s)" ???
thnx. i thought getline was only for ifstream/ofstream stuff :P

getline(cin, v);

I think he should have been able to figure that out from the hints provided. If not then there is no point in telling him.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.