The problem is when i entered letters the program keep saying
"Invaild number entered--Try again: ""Enter a double number: "
it just wont let me cin the number[count];
const int SIZE =20;
double* number = new double[SIZE];
int count = 0;
do {
cout << "Enter a double number: ";
cin >> number[count];
while (!cin.good() && !cin.eof()) {
cout << "Invaild number entered--Try again: ";
cin >> number[count];
system("PAUSE");
}
}while(!cin.eof());
Do you wanna only numbers in your program and ignore the letters? if yes, you can ignore strings data type in your program with the scanf() function. For example:
scanf("%[A-Z]s", str);
in this code, I ignore any char of A at Z.
----------------------
Sorry any english error, I from Brazil.
Ty. andrezc i never used scanf before, but i tried those scanf in my program. so what if a user entered a string instead of letters.
for Packetpriate, in this program i need to test for invaild number. for instance, if user entered a letter or a string, i should let user enter the number again.
I just dont get it why it doesnt go to if statement of cin.