uhhh strings and cin problems
In my attempts to figure out a way to store a sentence into a string variable I have come up with nothing. Either it stop at the first word or add the first word to the end.
ok... so I decided to try to find a way around it.
My goal is to compare the two sentences with each other.
ie
foo bar ar
compared to
foo bar ar
simple right...I guess for a beginner that is not so.
here is code I have tried
1 2
|
string firstTry;
cin >> firstTry;
|
What I got back was:
foo
I need the rest of the sentence...back to the drawing board.
1 2 3 4 5
|
string secondTryA;
string secondTryB;
string secondTryC;
cin >> secondTryA, secondTryB, secondTryC;
|
results:
foo bar arfoo
Ok the first time it didn't give enough and now it's giving to much... back to the drawing board.
1 2
|
char thirdTry[10];
cin thirdTry;
|
results:
foo bar arfoo
I am trying, really I am, but really this is c++. Storing an user input string in a variable should not be that hard.
I tried getline, but I couldn't get it to store in the variable. I thought maybe concatation is the way to go. I'll have to read up on it, and don't know if that will be another dead end.
Any suggestions....
Is C++ more for numbers, ints, and bools then for working with words?
Why is it adding the first word to the end?
How can I get it to leave the first word off the end to accurately compare it?
I've been at this all night and I would hate it all to be for nothing...help???