[Ajuda] Funзгo
#1

Fiz essa funзгo pra verificar se a string passada estб vazia, porйm sу retorna se tiver mais que dois espaзos, se tiver um espaзo diz que nгo estб em branco. Tambйm queria saber se tem como usar o foreach em strings pois nгo consegui. Alйm disso quando eu uso SendClientMessageToAll(-1, txt[i]) imprimi o que veio no txt e nгo a posiзгo da iteraзгo no for.

pawn Код:
stock emBranco(txt[]){
    if(strlen(txt) == 0) return true;
    for(new i = 0; i < strlen(txt); i++){
        if(strcmp(txt[i]," ")){
            return true;
        }
    }
    return false;
}
Reply
#2

pawn Код:
stock emBranco(txt[]){
    if(!strlen(txt) || txt[0] == '\0'){
        return 1;
    }
   
    for(new i = 0, e = strlen(txt); i < e; i++){
        if(txt[i] != ' '{
            return false;
        }
    }
    return true;
}
Reply
#3

isso tbm daria

pawn Код:
#if !defined isnull
    #define isnull(%1) \
                ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
#endif
Reply
#4

Arrumei:
pawn Код:
stock emBranco(txt[]){
    if(strlen(txt) == 0) return true;
    for(new i = 0; i < strlen(txt); i++){
        if(strcmp(txt[i]," ",false,1) == 0){
            return true;
        }
    }
    return false;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)