Strtok


Započeo Dragi, Februar 14, 2018, 21:16:49 POSLE PODNE

prethodna tema - sledeća tema

0 članova i 1 gost pregledaju ovu temu.

Detaljan opis problema: Ovako funkcija strtok nesto za***ava. Deklarisao sam tmp i izbacuje error 017, kad stavim new za te errore, pojavi se error 035.
Dio skripte:
CMD:call( playerid, params[] )
{
	if(UlogovanProvera[playerid] == 1)
		{
			//new tmp[128], strtok, cmdtext, idx, text;
			tmp = strtok(text, idx);
			if(!strlen(tmp))
			{
			    ShowPlayerDialog(playerid, DIALOG_CALL, DIALOG_STYLE_LIST, "Test","1\n2\n3\n4","Odaberi","Zatvori");
			    return 1;
			}

Znaci izbacuje error 017 za: tmp, text, Kada uklonim komentar onaj gore za new tmp, izbaci erorr 001, 029 za "tmp = strtok(text, idx);"
Moguce da je i moj neki propust i da mi je stao mozak.
Evo ovao sto sam dodao za funkciju strtok, standard uzeo sa wiki
strtok(const string[], &index)
{
	new length = strlen(string);

	while ((index < length) && (string[index] <= ' '))
	{
		index++;
	}

	new offset = index,
	    result[20];

	while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
	{
		result[index - offset] = string[index];
		index++;
	}

	result[index - offset] = EOS;
	return result;
}

Neke slike/video za lakse dobivanje pomoci(neobavezno):
Poslednja Izmena: Februar 14, 2018, 21:21:43 POSLE PODNE od |Gagi|


Citat: .ксундер poslato Februar 14, 2018, 22:06:23 POSLE PODNE
Cemu strtok kada imas sscanf?

hardcore mode?

koristi sscanf


“Without requirements or design, programming is the art of adding bugs to an empty text file.” - Louis Srygley