I need help!

I'm new with c++ and i have an assignment
where I have to Prompt the user for a line of text and then Output that line in all capitals.
but it just outputs the first word and the second word is just ignored how can i fixed that....

here is what i have so far

#include <iostream>
#include <string>
#include <cctype>

using namespace std;

int main ()


string line ;

cout << "Enter a line of text"<<endl;
cin >> line;

for( int x=0 ; x < line.length() ; ++x) line[x] = toupper( line[x] );

cout<< line << endl;

The >> operator only copies the first word.
If you want the whole line, use getline(cin,line).
Thank you so much it works!!
Right i'm going to also help you on the forums as well as your problem here (user friendly posts = better/quicker answers)

Firstly there is a "Beginner" C++ forum for newbies to the language, here is for more intermediate-expert stuff... (Just to be kind to the people having trouble with more difficult things)

Secondly please use the "[ code ]" and "[ /code ]" notations around your source code (without the spaces) to make it easier to distinguish from your question.

And finally why do you have cout within its own scope... you also haven't created a scope for the for loop...
Try this:

for(int x=0; x<line.length(); x++){
    line[x] = toupper(line[x]);
cout << line << endl;

Bye byes :D
I'm sorry for all the inconveniences, I'm also new in this website.
Topic archived. No new replies allowed.