   flush my god forsaken io
  I'm at a loss.  I've tried all combinations of cin,cin.get,gets,cin.getline..the function works fine the first run through.  After you modify your stats, if you're not happy with your toon, it loops back to re-run creation.  the endline character is automatically going to input and giving an annoying "You chose . Are you happy with this name?"  I can't for the life of me figure out how to clear this endline from the buffer, I've fflushed everywhere.  Can someone see if you can see the issue?int main(int argc, char** argv) { srand((unsigned)time(NULL));    bool eval;    toon character;    system("clear");    do    {  eval=happy(character);    //any chance passing character is the issue?    }    while(eval==false);return (EXIT_SUCCESS);}char getname(toon& character)    //name function works fine first run through,{  //yes/no works fine.    int MAXNAME=100;    char name[MAXNAME];    char dec;    char* decide=&dec    int len;    do    {    system("clear");    fflush;    cout<<"Enter desired name"<<endl;  cin.getline(name,MAXNAME-1);  cout<<"You chose: "<<name<<". Are you happy with this choice?";    //this is where my   //newline is depositing if happy()   //returns false    gets(decide); //well really I guess it's here.    fflush;    }    while((dec!='Y')&&(dec!='y'));strcpy(character.name,name);}bool happy(toon& character)  //creation function, the newline is getting{   //stuck in the buffer at the end of this    char dec; //function (I think).    char* decide=&dec    system("clear");    while((dec!='Y')||(dec!='y'))    {   fflush;   attrib(character);   impprof(character);   system("clear");   cout<<"Final Character:"<<endl;   prof(character);   cout<<"\nAre you happy with your character? (yes or no)"<<endl;   cin>>decide;    //I've tried cin.get,gets,etc here.   fflush;    //flushing also isn't working.    if((dec=='Y')||(dec=='y'))  {   return true;    }   return false;    }}The only fix I've found is to totally remove the endline by requiring additional input.  if I put the following in the getname() function, before the do/while loop:cout<<"Press <enter> to continue"<<endl;cin>>test;   //added char test; declaration to my variables.This fixes the problem, but I'd prefer not do it if I can help it.Thanks in advance.   
  I would expect that cin.ignore(1) ought to do the trick: it just ignores whatever is the next character in the input, in this case the newline character.   ;  First off, if you're going to post a large amount of code you should consider using the [code] or [source] tags.As for the actual problem, this is a pretty common issue when mixing using the extraction operator and getline() on a stream. What I recommend doing is always using getline() to get your data and then passing the result of getline() to a std::stringstream and performing extraction on that stream. For example, if you wanted to extract an int from input you would do something like:  std::string line;  std::getline(std::cin, line);  std::stringstream sstr(line);  int i;  sstr >> i;In addition to regularizing newline conventions for input, this also eases error handling when a line doesn't actually contain the type you are trying to extract.ignore(1) isn't a robust solution here because when dealing with the extraction operator the next character isn't guaranteed to be a newline.Also, when you are trying to use a function, you really need to use parentheses to call it. fflush; by itself is a legal C++ statement, but it doesn't actually do anything. Your compiler should give you a warning about this kind of behavior. For example, with MSVC it's a C4551, which is a level 1 warning.   