I believe this is a getline problem. I am trying to get a string in with a space. EX: getline(cin, fullname); I have about 4 of these getline functions. I use cin once to input a double and so I use cin.ignore() to clear the last getline. The problem occurs when I try to output this information. Some of the data is lost or outputed in the wrong spot for some reason. Have no clue why. Also the first getline function makes hit enter twice for it to take in the string i entered. This is for a friend or mine. thanks.

Code:
/*

=========================================================================

Class Program:

This program asks you questions and outputs the answers

Author:  CPTR 212 Fall 2004 Class

=========================================================================

*/

 

#include <iostream>

#include <string>

using namespace std;

 

class Class

{

            public:

                        void obtainName();

                        void obtainFavoriteClass();

                        void obtainNotFavoriteClass();

                        void obtainGPA();

                        void obtainFavoriteTeacher();

                        void obtainNotFavoriteTeacher();

                        void showClass();

            private:

                         string Name,

                                                FavoriteClass,

                                                NotFavoriteClass,

                                                FavoriteTeacher,

                                                NotFavoriteTeacher;

                         double GPA;

 

};

 

int main()

{

            int loop = 1;

            while (loop == 1)

            {

                        Class college;

                        college.obtainName();

                        college.obtainFavoriteClass();

                        college.obtainNotFavoriteClass();

                        college.obtainGPA();

                        college.obtainFavoriteTeacher();

                        college.obtainNotFavoriteTeacher();

                        college.showClass();

                        cout << "\n Would you like to do it again?\n(1)Yes\n(2)No\n";

                        cin >> loop;

            } //end while

            return 0;

} //end main

 

void Class::obtainName()

{

            cout << "What is your name? ";

            getline(cin, Name);

}

 

void Class::obtainFavoriteClass()

{

            cout << "What is your favorite class? ";

            getline(cin, FavoriteClass);

}

 

void Class::obtainNotFavoriteClass()

{

            cout << "What is your least favorite class? ";

            getline(cin, NotFavoriteClass);

}

 

void Class::obtainGPA()

{

            cout << "What is your grade point average? ";

            cin.ignore(1024, '\n');

            cin >> GPA;

}

 

void Class::obtainFavoriteTeacher()

{

            cout << "Who is your favorite teacher? ";

            getline(cin, FavoriteTeacher);

}

 

void Class::obtainNotFavoriteTeacher()

{

            cout << "Who is your least favorite teacher? ";

            getline(cin, NotFavoriteTeacher);

            cin.ignore(1024, '\n');

}

 

void Class::showClass()

{

            cout << "\nName: "

                         << Name

                         << endl

                         << "Favorite Class: "

                         << FavoriteClass

                         << endl

                         << "Least Favorite Class: "

                         << NotFavoriteClass

                         << endl

                         << "Grade Point Average: "

                         << GPA

                         << endl

                         << "Favorite Teacher: "

                         << FavoriteTeacher

                         << endl

                         << "Least Favorite Teacher: "

                         << NotFavoriteTeacher

                         << endl;

}