Jump to content

[SOLVED] Simple question about string whitespace in C++?


Recommended Posts

All I am wondering is why is cin cutting out my spaces.  If I type "Time to die" into the command line it returns "time".  If I type "Today is the time I am performing this test" it returns "Today".  This is kind of strange.  Any reason why spaces are being cut out..or more of it finds the first space and everything after it is removed.

#include <iostream>
#include <string>
using namespace std;

int main() {
string time;
cout<<"What time is it? \n";
cin>>time;
cout<<"Now that you entered the time...it is \n";
cout<<time << "\n";

system("PAUSE");
return 1;
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.