Clearing entire string with strcpy()? - 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: Clearing entire string with strcpy()? (
/showthread.php?tid=660818)
Clearing entire string with strcpy()? -
v1k1nG - 14.11.2018
PHP код:
new str[32];
strcpy(str, "\0");
strcpy(str, "");
strcpy(str, EOS);
Are them correct? I am planning to use the same string again after formatting it.
Re: Clearing entire string with strcpy()? -
Freaksken - 14.11.2018
strclr
Re: Clearing entire string with strcpy()? -
v1k1nG - 14.11.2018
Thank you!
Re: Clearing entire string with strcpy()? -
dotSILENT - 14.11.2018
Just do str[0] = '\0', there's no need to overwrite the entire array and just adds an unneccessary overhead.
C-style strings should be always ended with an EOS ('\0), that's how all string manipulating functions work. strlen() counts characters until it finds a \0
And anyway, if you use format() there's no need to do this because it overwrites the entire string with newly formatted one anyway, you need to use that only if you want to for example use strins()