Ok, so I am trying to write a string that returns what I type in and it works until I start putting spaces between my characters. How would I go about fixing the problem of the string not returning anything after I hit the space bar? Thanks in Advance
#include <string>
#include <iostream>
using namespace std;
Hello. All you need to do is replace your cin with a getline statement. If I understand it correctly, cin (or maybe it's the >> operator or the combination of the two) will only ready your string until it hits a blank space and it stops. The use of getline here will avoid that issue. It'll read the string even if there are spaces.
For example, as you know, if you enter "Hello World" as the cin statement, the program only outputs "Hello" to the screen. Again, your current cin statement only reads until it hits a blank space. If you were to replace the cin with getline, you should be fine. Try this.