Need to make a function

Hello everyone!! I'm having a small problem creating a getValue function. I think I'm making this more difficult than it should be. I think I got my error message right but setting up the function has me confused.





1
2
3
4
5
6
7
8
9
10
int getValue(string prompt,int lowerBound, int upperBound)
{

while(prompt<lowerBound || prompt>upperBound)
{
cout << endl<< "Sorry, wrong number entered. Please enter number: ";
}
string prompt;
cout << endl<< prompt << "between "<< lowerBound<< " and "<< upperBound<< ": ";
}


any help would be greatly appreciated. Thanks

At line 4 you are comparing a string with integers, you have to convert it to a number.
The while loop makes no sense as if its condition would be true it will never change, it will just continue printing "Sorry, wrong number entered. Please enter number: "
Besides,you can use "if" instead of "while".
Topic archived. No new replies allowed.