Can't figure out how to use strmid properly.
#1

Hello.

Код:
	new ID,dest[32];
	new src[32] = "/tocar 20";
	strmid(dest,src,6,strlen(dest));
	sscanf(dest, "i", ID);
	printf("tele id: '%s' '%d'",dest,ID);
Running this code shows that strmid copies nothing to destination string therefore sscanf cant work. However if I switch dest and src then dest will be full string. Could anyone point me out how can I copy just a number from that string?
Reply
#2

You know, you can tell sscanf to skip the string literal.

pawn Код:
sscanf(src, "'/tocar 'd", ID);
Reply
#3

That is because you are telling the function to end writing at index 0 (as strlen(dest) will return 0, as it hasn't been initialized). You want to write the string length of src instead.

https://sampwiki.blast.hk/wiki/Strmid
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)