vendredi 27 février 2015

string validation isalpha always false?

So I've got a function for validating a string, and I've looked at the same issue I am getting elsewhere but fixes don't seem to work for my code any help would be appreciated :)



bool validate(string s)
{
for (int i = 0; i < s.size(); i++)
{
if (isalpha(s[i]) != 0)
{
return false;
}
if (isspace(s[i]))
{
return false;
}
if (ispunct(s[i]))
{
return false;
}
}
return true;
}


The problem I am getting is it always returns false no matter what I've tried with and without != 0 but this doesn't change anything, generally the string I'm putting in is "blue" for anyone that is curious to how I am testing this.


Aucun commentaire:

Enregistrer un commentaire