Question sizeof
#1

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.
Reply
#2

I doubt it
Reply
#3

It's the same
Reply
#4

No, they both mean 50.
Reply
#5

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.
Reply
#6

maybe the more time u says is like 10 milliseconds so it doesn't really matter but using numbers is a lil bit faster
Reply
#7

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
Reply
#8

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...
Reply
#9

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.
Reply
#10

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)