Hello straslak,
Found it.
The use of
cin.ignore();
before the "getline" statements is unnecessary.
cin.ignore();
should only follow something like
cin >> aVariable
. The reason is that
cin >> aVariable
leaves the newline character in the input buffer which needs to be removed before the use of a "getline" which will extract the new line and move on.
The more accepted way of using "ignore" is
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); // <--- Requires header file <limits>.
And if you will be using "Windows.h" you may need to write your header files as:
1 2 3
|
#include <Windows.h>
#undef max
#include <limits>
|
This is what I found works for me with VS.
So, comment out or remove all the
cin.ignore();
lines and the program will work better.
Since you are using "<iomanip>" you could do something like:
1 2
|
std::cout << std::setfill('*') << std::setw(200) << ' ' << std::endl;
std::cout << std::setfill(' ');
|
And adjust the 200 as needed or use a variable defined as a const.
"Sleep()" is specific to Windows and not able to be used by everyone. Something you could do is define a constant variable at the beginning of the program with a given value and then use sleep as
Sleep(sleepTime);
. This way you will only have one place to change if you need to change the time.
"system()" anything should be avoided at all times as it could leave your program vulnerable to attack.
I have a function for Windows that will clear the screen if you are interested.
Hope that helps,
Andy