error C2059: syntax error : 'return'

Ive got this error
error C2059: syntax error : 'return'
Ive tried looking at what people with simmilar problems have posted but it doesnt seem to help me. The piece of code is a function im trying to use to make sure what is being entered is a double.

double getval()//function to enter values and check that they are numbers
{
double val=0;
char temp_val[15];
int v=1;
do while(v!=1)
{
cin.ignore(1);
cin.getline(temp_val,sizeof(temp_val));
istringstream Stream(temp_val);
if(Stream >> val)
{
v=1;
}
v=0;
cout <<"Your input was invalid please enter numbers only" << endl;
}
return val;
}

Im pretty new to programming so please go easy on me if ive done something very stupid here.

Thanks in advance.
your do-while is wrong

1
2
3
4
5
6
7
8
9
// wrong
do while(v != 1)
{
}

//right:
do
{
}while(v != 1);


The while comes after the 'do' block, not before it. Also notice the while has a semicolon after it.
cant believe i didnt spot that.

Thanks alot for the help.
Topic archived. No new replies allowed.