My code requires the validation of a string that starts with two letters and ends with six numbers. So, an example would be br474897. This is what I got so far:
bool GetNID(char buf[])
{
int i= 0;
int length;
bool valid = false;
cin.getline(buf, 30);
length = strlen(buf);
for (i = 0; i < length; i++)
{
if ((i == 0) || (i == 1))
{
if ((buf[i] < 'a') || (buf[i] > 'z'))
{
valid = false;
}
else
{
valid = true;
}
}
if (i > 1)
{
if (buf[i] < 0 || buf[i] > 9)
{
valid = false;
}
else
{
valid = true;
}
}
}
return valid;
}
Thanks in advance for your help.