Probelm when entering a string
I've got a bit of code working so it will accept the number you put it and use it else where (no need to show you this), but if a string/letter is entered then the program crashes. I'd like it to come up with an error if a string is entered.
Not an essential part of code for the program, but i'd like to get it as bug free as possible, and I cant seem to find how to fix this anywhere.
Code:
valid = 0;
do
{
cout << "\n enter the number of songs you wish to enter: ";
cin >> songs;
if (number < 1 || number > 100)
{
cout << "\n enter again between 1 and 100";
}
else
{
valid++;
}
}while (valid < 1);
Anyone help?
Thanks in advance.