Valid letters problem
#3

This is probably the shortest I can write this. And you get a free handy function with it.

pawn Код:
stock IsValidCharacters(characters[])
{
    for(new i, j = strlen(characters); i < j; i++) // go over each character in the string separately
    {
        if(!('A' <= characters[i] <= 'Z' || 'a' <= characters[i] <= 'z' || '0' <= characters[i] <= '9' || in_array(characters[i], { '.', ')', '(', '[', ']', '=', '$', '@' })))
            return false;
    }
    return true;
}

stock in_array(needle, const haystack[], size = sizeof haystack, &index = 0)
{
    for(new i; i < size; i++)
    {
        if(haystack[i] == needle)
        {
            index = i;
            return true;
        }
    }
       
    return false;
}
Reply


Messages In This Thread
Valid letters problem - by uZ1 - 11.10.2014, 20:32
Re: Valid letters problem - by Chenko - 11.10.2014, 21:55
Re: Valid letters problem - by Vince - 11.10.2014, 22:10
Re: Valid letters problem - by uZ1 - 11.10.2014, 22:17

Forum Jump:


Users browsing this thread: 1 Guest(s)