Simple function programme
Im writing a function that asks someone to put in a range from one to five and the function is to be passed through a string. I;d likke the function to return the input value if in range, or minus one if out of range. to do this, i'd like it to do something like this...
Code:
value=getval("Please enter a value in the range 1 to 5")
Code:
#include <iostream>
using namespace std;
void getval ()
{
char string[1];
cout << "please enter a value between 1-5: ";
cin >> string;
cout << endl <<string <<endl;
}
int main ()
{
getval ();
system("pause");
}
Can anyone help?