Question sizeof - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Question sizeof (
/showthread.php?tid=251699)
Question sizeof -
Raimis_R - 28.04.2011
What is the difference between the formating:
pawn Код:
new string[50];
format(string,sizeof(string),"%s...",...);
In this example i'm using sizeof function but i know string size
and in this:
pawn Код:
new string[50];
format(string,50,"%s...",...);
Does it have an impact on the server if i know string size but i using sizeof in formating.
Re: Question sizeof -
Lorenc_ - 28.04.2011
I doubt it
Re: Question sizeof -
aircombat - 28.04.2011
It's the same
Re: Question sizeof -
MadeMan - 28.04.2011
No, they both mean 50.
Re: Question sizeof -
Blantas - 28.04.2011
Quote:
Originally Posted by aircombat
It's the same
|
Could you prove it, please?
I think using extra function ( sizeof ) it takes more time to proceed the code.
Re: Question sizeof -
aircombat - 28.04.2011
maybe the more time u says is like 10 milliseconds so it doesn't really matter but using numbers is a lil bit faster
Re: Question sizeof -
MadeMan - 28.04.2011
Quote:
Originally Posted by Blantas
Could you prove it, please?
I think using extra function ( sizeof ) it takes more time to proceed the code.
|
sizeof is not a function, it's an operator
Re: Question sizeof -
Blantas - 28.04.2011
Quote:
Originally Posted by MadeMan
sizeof is not a function, it's an operator
|
Hm.. I didn't know that. Thanks for the information. So using it would be the same as using numbers? I'm confused...
Re: Question sizeof -
MadeMan - 28.04.2011
Quote:
Originally Posted by Blantas
Hm.. I didn't know that. Thanks for the information. So using it would be the same as using numbers? I'm confused...
|
Yes.
Re: Question sizeof -
xRyder - 28.04.2011
Sizeof as the name sais will get the
size of some array. In your case you declared string as a 50 cells big array. So it will get that "50" and place it instead of "sizeof(string)" when you compile it. So like someone already said, it's the same.
Edit: Wow, I had some big delay between when I clicked to post this, and when that actually got posted.