Posts: 1,506
Threads: 13
Joined: Jun 2015
23.06.2018, 17:45
(
Последний раз редактировалось Logic_; 25.06.2018 в 03:01.
)
Quote:
Originally Posted by Calisthenics
You still call strlen many times and it does work, just tested it to confirm.
pawn Код:
main() { OnPlayerText(0, " it works."); }
public OnPlayerText(playerid, text[]) { for (new i = 0, j = strlen(text); i < j; i++) { if ('a' <= text[i] <= 'z') { //text[i] = toupper(text[i]); text[i] -= 32; break; } } printf("OPT: \"%s\"", text); return 1; }
|
You can alternatively use
if (new i; text[i] != EOS; i++) for the loop. Your code is better than Lokii's.