when i run it and enter the character 'a' for example
it outputs:
1 2 3 4 5 6
enter option:
a
enter option:
enter option:
i suspect this is because when i press the 'a' key and then hit the enter key, the input stream reads it as two characters ('a' and the newline character)
So then when the next loop runs the cin.get reads the newline character that is still in the buffer, rather than pause and wait for new input.
but i dont want it to count the newline character as an option
not sure exactly why that behavior happens, since istream get() function is supposed to read a single character. In any case, replace line 5 with std::cin >> option; , which does a formatted input read much more smoothly.
The problem is that cin is buffered, but get reads only one char so the '\n' remains in the buffer.
You could use std::cin.ignore(255, '\n'); to read the '\n'.
If you use Visual Studio and don't care about standard conformity you could use _getch or _getche