LordoftheFly 22 Newbie Poster

I'm having trouble with this section my code and am hoping that you can help me diagnose and solve the problem. I'm not sure if it makes a difference, but I compile and run my code in Cygwin.

The problem:
At run time when the program asks for the user input I can input somethimg like: "Guybrush Threepwood Throe" and the code will run just fine, but if I type the same thing and then use the left arrow button to move the cursor back over the input to make a correction (for instance to change the third word of the input from "Throe" to "Three"), the program will ignore (or seem to ignore) all of my "cin.ignore(1000, '\n');" and "cin.getline(input1, 31, '\n');" commands. I'm aware that you're not technically supposed to use the arrow keys in Cygwin, but I'm trying to make my code fool-proof.

Why does this happen, and assuming the user will eventually use those arrow keys, how can I prevent the undesired side-effects?

#include <cstdlib>
#include <iostream>
using namespace std;

int main ()
{
  char input1[31];
  char default1[31] = "                              ";
  int success = 0;
  int tries = 0;
  while ((success != 0) && (tries < 4))
  {
     cout << "[By what name shall you be known? Max: 30 Characters]" <<   endl;
     cout << ":" << endl;
  // Point of possible conflict follows immediately
     cin.getline(input1, 31, '\n');
     if (((input1[0] > 64) && (input1[0] < 91)) || ((input1[0] > 96) && (input1[0] < …
Salem commented: Excellent first post - code tags, environment, statement of problem and example code. Everyone else should learn from this! +22