Quote:
Originally Posted by Napoleon_be
For example this is hardcoding your array size:
PHP Code:
new szName[32];
get_user_name(id, szName, 31);
This is just a simple example, if you declare your arrays globaly and need to retrieve the array size multiple times, you should use charsmax() instead of hardcoding the array size everytime. When using charsmax(), you only have to change the array size (if u ever have to) and everything will be fine.
For example, if szName[32] ever becomes szName[64], you have to redo every single line where you used that array.
charsmax() fixes this problem.
PHP Code:
new szName[32];
get_user_name(id, szName, charsmax(szName));
charsmax is the same as sizeof() - 1. The function itself says it, maximum characters available for the array.
|
Well, thanks i understand but what is better sizeof() -1 or charsmax()
__________________