charmax & sizeof
In one 'Glow' plugin i found these lines:
PHP Code:
PHP Code:
By the way would he creat name[64]? Aren't [33] is enought? |
Re: charmax & sizeof
charsmax is 100% identical to doing sizeof-1 seeing as it is macro for it
33 is plenty since a players name is only 32 characters long at most. |
Re: charmax & sizeof
charmax --> charsmax
one question, in this example it's better use 32 than charsmax? you spare to call charsmax, a little better performance? |
Re: charmax & sizeof
Its a same thing, for example: charsmax(szName); or sizeof(szName) -1);
Its ready a max length of an string and count to -1. Its working nice with a 32, 64, 128, 320 400 512 and all other size of Strings. |
Re: charmax & sizeof
charsmax (and I think sizeof as well) is replaced at compile, so there is no performance issue with using it
|
Re: charmax & sizeof
Quote:
|
Re: charmax & sizeof
I never use charsmax for known array sizes anyways. More readable for me since you always get remembered how long the string can be :)
|
Re: charmax & sizeof
if we have:
Code:
new string[20];sizeof(string)-1 will return 19 charsmax(string) will return 19 That's everything you have to know |
Re: charmax & sizeof
Quote:
|
Re: charmax & sizeof
Quote:
|
| All times are GMT -4. The time now is 10:46. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.