AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Variable Size (https://forums.alliedmods.net/showthread.php?t=25581)

capndurk 03-16-2006 13:11

Variable Size
 
I saw a post in here the other day that asked about the following:

variable[32]
get_user_name(id, variable, 31)

Why is it that the size is 32, but the maximum number of characters is 31? Can't they be the same number?

I don't think that question was properly answered, so if someone could tell me why, it would be greatly appreciated.

v3x 03-16-2006 13:12

It's always the variable's length minus one.

pixel3 03-16-2006 13:13

I'm not sure but I belive that the last byte is 0 that marks the end of string ...

MattOG 03-16-2006 13:14

cos 32 is the TOTAL amount of spaces, yet counting starts at 0, so you only go up to 31 ;P

pixel3 03-16-2006 13:15

Quote:

Originally Posted by MattOG
cos 32 is the TOTAL amount of spaces, yet counting starts at 0, so you only go up to 31 ;P

oo.. :)

BAILOPAN 03-16-2006 13:16

Quote:

Originally Posted by pixel3
I'm not sure but I belive that the last byte is 0 that marks the end of string ...

this and v3x's remark are right, you've got 32 cells (from 0 to 31), but the last one (cell 31) is reserved for a terminating '0'. you can only use the first 31 cells (0-30) for the string contents.

MattOG 03-16-2006 13:17

so is my understanding of it, i may be wrong :oops:

::edit::

score -1 for me :p

capndurk 03-16-2006 14:37

Quote:

Originally Posted by BAILOPAN
you've got 32 cells (from 0 to 31), but the last one (cell 31) is reserved for a terminating '0'. you can only use the first 31 cells (0-30) for the string contents.

Thanks everyone for your answers, now it's time to mess around with strings. :D


All times are GMT -4. The time now is 16:36.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.