bool isValidDouble (char numbers [], int size)
{
int count;
int Deccount = 0;
for (count=0;count <Size; count ++)
{ if (isdigit(Numbers[count]))
return true;
else if (((Numbers[count]) == '.') && (Deccount == 0))
{
Deccount++;
return true;
}
else
return false;
}
}
void readDouble (char Numbers[], int Size)
{
if (isValidDouble(Numbers, Size))
cout <<"That is a valid number"<<endl;
else {cout<< "That is not valid. Please retry"<<endl;}
}
void main ()
{cout<<"Please enter a real number:"<<endl;
cin.getline(Numbers,Size);
readDouble(Numbers,Size);
}
Please adjust your code tags. Replace the words with your code; don't put the code inside one of the tags itself.
The problem is that you are returning from your function after checking only the first char of your array. You should return true only if you get through the entire loop without hitting any place where you need to return false.