Alphanumeric check
#1

Hello,

is there any way to check if the string is only alphanumeric characters? I need this for password creation.
Reply
#2

Yes, there is a way .


I did a function to you which do this, it should solve your problem :


pawn Код:
stock OnlyAlphaNumericCharacters(const string[])
{
    new z = 0;
    for(new x, y = strlen(string); x != y; x++)
    {
        if((string[x] >= 48 && string[x] <= 57) || (string[x] >= 65 && string[x] <= 90) || (string[x] >= 97 && string[x] <= 122))
        {
            z++;
        }
    }
    if(z == strlen(string)) return true;
    else return false;
}

Maneer to use:


pawn Код:
new lol[3] = "xD";
if(OnlyAlphaNumericCharacters(lol)) print("The variable have only letters and/or numbers);


I hope that i have helped .
Reply
#3

Thank you <3
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)