>>The problem is that a cin for a numeric will leave the ENTER key in the keyboard buffer and that is OK with cin and other numbers but not with strings, thus we must remove it on our own.
This is correct. However, the code you posted has several errors that that should be addressed first.
for (
{
cout << "Please enter your name: ";
cin.getline Student[index].Name);
cout << "Please enter your GPA: ";
cin.getline Student[index].GPA;
cout << "Please enter your Major: ";
cin.ignore Student[index].Major;
}
1) To be kind I'll assume you left out the parameters of the for loop on purpose. If not, you either need to complete the for() statement by adding the appropriate parameters, or remove it and the curly brackets and call the function repeatedly from another location if you want to enter more than one students information.
2) You also need to use an argument list with the getline() and and ignore() functions.
getline() takes three arguments, but there are two different versions of getline() depending on which type of string you are using. If you are using a Cstyle string as implied by your post, then the first argument is the name of the string, the second is the maximum number of elements to be entered into the string, and the third is which char acts as a terminating char if EOF isn't found or the maximum number of char isn't entered before the terminating char is found. The third parameter can be any legal char but defaults to the newline char. So it would be something like:
cin.getline(myString, x); //if you use the default newline char or
cin.getline(myString, x, '*'); //if you want to terminate input after x number of char or with finding an asterix or if finding EOF.
ignore() takes two char, the first being how many char to ignore, and the latter being what char to terminate ignoring on. You don't have to indicate any argument if you only want to ignore one character as the first argument defaults to 1 and the second to EOF.
3) Once though errors have been corrected, then you will want to move the call to ignore() to before the call to getline(), not after, to deal with any lingering char in the stream after a call to >>.