How can I print string from number index to end? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How can I print string from number index to end? (
/showthread.php?tid=522481)
How can I print string from number index to end? -
Riwerry - 27.06.2014
Hello guys, how can I print string from cell what I want to to string end?
H E L L O W O R L D
0 1 3 4 5 6 7 8 9 10 11
Then I want to output only "World",
printf("%s", string[6]);
not working for me.
Thankls
Re : How can I print string from number index to end? -
Clad - 27.06.2014
pawn Код:
new string[6] = "World";
printf("%d", string[0]);
Re: How can I print string from number index to end? -
Riwerry - 27.06.2014
It outputs me ascii of 'W'
Re: How can I print string from number index to end? -
Konstantinos - 27.06.2014
I don't really understand what you want. If you just print the whole string:
Using an index and %s placeholder will print all the characters from that index until the end of string.
Using an index and %i or %d placeholder will print numbers.
Re: How can I print string from number index to end? -
Riwerry - 27.06.2014
I want to print part of string.
Re: How can I print string from number index to end? -
Konstantinos - 27.06.2014
Quote:
Originally Posted by Konstantinos
...
Using an index and %s placeholder will print all the characters from that index until the end of string.
...
|
Let's say you want to print the last 3 characters of it:
pawn Код:
printf("%s", string[2]);
// string contains "World" and it will print "rld".
If the part of the string is at the beginning, then extract it:
https://sampwiki.blast.hk/wiki/Strmid
Re: How can I print string from number index to end? -
Riwerry - 27.06.2014
Thanks, it works. :P