I am working on a little program and for some reason when I try and use the getline() it is giving me a lot of problems here is what I did
getline(cin, s.name); //it skips this altogether
cout<<"Test "<<s.name; //here it will display test but nothing else
getline(cin, s.address);
getline(cin, s.city);
getline(cin, s.state);
cin>>s.zip;
is there anything I am doing wrong or need to do extra to it (and yes I #include <iostream> I even did <iomanip> just to see if that would help)?
I don't quite understand what he should do in this situation, even with the link you provided cire. I understand it is frustrating to you when the "obvious" answer is ALREADY answered somewhere... but I still don't get it.
You have a different problem than the one described in the faq. You are mixing formatted and unformatted input. formatted input leaves trailing newlines in the stream. Your unformatted input, getline, stops when it encounters a newline.
#include <iostream>
#include <string>
usingnamespace std;
int main()
{
cout << "Please enter two words: " << endl;
string b, c;
cin >> b >> c;
cout << "I understood: "
<< b << ", and "
<< c << endl;
cout << "Now, type in a whole line of text, "
<< "with as many blanks as you want.:"
<< endl;
if ( cin.peek() == '\n' )
cin.ignore();
string wholeLine;
getline(cin, wholeLine);
cout << "I understood: \"" << wholeLine << "\"" << endl;
return 0;
}