getline won't recognize first character

Hey there,

This is my first posting on these forums. Thank you in advance for your time.

Here is the code I am working with, isolated
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
    std::cout << "Welcome to Spaceport Drago." << std::endl;
     std::cout << "What is the name of your Vessel?" << std::endl;
     getline (cin, Incoming.Name);
     std::cout << "Hail " << Incoming.Name << std::endl;
     std::cout << "Under Standard Galactic Charter, what single letter Class is your vessel?" << std::endl;
     std::cin >> Incoming.VesselClass;
     std::cout << "And what is the name of the captain(s) onboard? \n";
     std::cin >> Incoming.Captain;
     getline (cin, Incoming.Captain);    
     std::cout << "And what galaxy are you originating from?" << std::endl; 
     std::cin >> Incoming.FatherGalaxy;       
     getline (cin, Incoming.FatherGalaxy);
     std::cout << "This is your Station Charter as we have it." << std::endl;
     std::cout << "Vessel Name: " << Incoming.Name<< std::endl;
     std::cout << "Vessel Class: " << Incoming.VesselClass << std::endl;
     std::cout << "Captain(s): " << Incoming.Captain << std::endl; 
     std::cout << "Father Galaxy: " << Incoming.FatherGalaxy << std::endl; 


What I am trying to do:
I would like the ending output to look like this

"This is your Station Charter as we have it.
Vessel Name: User inputted string1
Vessel Class: User inputted char
Vessel Captain(s): User inputted string2 (that can be inputted in this fashion: Captains Name 1, Captain's name 2, Captain's name 3. All as one continous string)
Father Galaxy: User inputted string 3"

What is not working:
If Incoming.Captain or Incoming.FatherGalaxy are inputted as one word or a value with spaces, the first value before the space is dropped.

What I have tried:
-I have tried placing \n in several different places, including in the brackets of getline
-getting rid of cin
-changing location of Incoming.VesselClass
-using cin.ignore() after cin

I have a feeling this is resulting from some fundamental misunderstanding of the getline function, but I could be wrong. I searched on the internet and in the forums but I couldn't figure out how some of the code in other users getline problems would potentially apply to me as I am still pretty new at C++. Once again, Thank you so much for your time!
It is because you are combing the >> operator with getline(). Just use getline() by itself, and don't use cin >>.
Thank you, that worked. For some reason, I thought I had tried that earlier and it had only resulted in the queries running together and not making the input work out. I'm gonna go back now and see what I forgot to delete to make it do that. I feel kind of bad for asking since it was such a simple fix haha. thanks again.
Don't worry about it. ^_^
Topic archived. No new replies allowed.