   common cin.getline error
  I'm playing around with an easy chapter exercise that takes input from the user and stores it into a structure. I'm using cin.getline and one cin in a while loop for the input and I sort of know what kind of error this is, but it just won't work.the code looks like this right now:#include <iostream>#include <vector>#include "golf.h"using namespace std;int main(void) {    vector<golf> players;  while (1) {   golf player; cout << "Skriv in ett namn: ";   cin.getline(player.fullname, 40);  cout << "Skriv in handikapp: ";   cin >> player.handicap; if (!setgolf(player))  break;   else   players.push_back(player);    }   for (int i=0;i<players.size();i++) {   cout << players.fullname << endl;   cout << players.handicap << endl;    }  while(cin) cin.get();    return 0;    }I have tried cin.ignore and all that functions that removes the buffer etc. I've searched around everywhere but nothing works. It skips the first line after the first two inputs in the loop. Adding an extern getline and cin won't work in this case either. Am I missing something?   
  For line input, you might be better off using this:#include <string>using std::getline;string input;getline(cin, input); // read arbitrary length stringFor flushing the cin buffer, use this:#include <limits>using std::numeric_limits;cin.ignore(numeric_limits<int>::max()); // ignore everything up to the cin buffer size limit or newline   ;  Actually I hate using chars in general, but the exercise was using chars so I used it too. When I use cin.ignore(numeric_limits<int>::max());, the program pauses where I put it and it won't continue. Tried to put it right above cin.getline, in the middle of cin.getline and the cin and below everything, nothing of them worked.Forgot to mention that when I replace cin.getline with a regular cin the problem still remains, that's really strange.   