strfind
#4

Quote:
Originally Posted by Kraeror
Посмотреть сообщение
I have just fixed my code, I did really stupid mistakes, so thanks for your help, but I did it myself. I'm still learning
Here is how I fixed it:
PHP код:
bool:OnlyLetters(const text[])
{
    new 
chars strlen(text)+1;
    for(new 
'a'<= 'z'i++)
    {
        new 
string[256];
          
format(stringsizeof(string), "%c"i);
        for(new 
0<= strlen(text); l++)
        {
            if(
strcmp(text[l], " "true) == 1)
            if(
strcmp(text[l], stringtrue) == 1){} else chars--;
        }
        if(
chars != strlen(text)) return false;
        else return 
true;
    }
    return 
false;

That code won't work.You are over complicating your code.There's no need for that string variable itself and the outer loop iterates only once.A string is collection or array of characters.You can check each character one by one and check if it is not alphabet(as i mentioned in pseudo code in above post).Or just use regular expression "^[A-Za-z]+$"
Reply


Messages In This Thread
strfind - by Kraeror - 08.12.2018, 12:26
Re: strfind - by SyS - 08.12.2018, 12:51
Re: strfind - by Kraeror - 08.12.2018, 12:55
Re: strfind - by SyS - 08.12.2018, 13:08
Re: strfind - by Kraeror - 08.12.2018, 15:38
Re: strfind - by SyS - 08.12.2018, 15:46
Re: strfind - by Kraeror - 08.12.2018, 19:10

Forum Jump:


Users browsing this thread: 1 Guest(s)