Raised This Month: $ Target: $400
 0% 

Variable Size


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
capndurk
Senior Member
Join Date: Feb 2006
Old 03-16-2006 , 13:11   Variable Size
Reply With Quote #1

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.
capndurk is offline
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 03-16-2006 , 13:12  
Reply With Quote #2

It's always the variable's length minus one.
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
pixel3
Senior Member
Join Date: Dec 2005
Old 03-16-2006 , 13:13  
Reply With Quote #3

I'm not sure but I belive that the last byte is 0 that marks the end of string ...
__________________
pixel3 is offline
MattOG
Senior Member
Join Date: May 2005
Old 03-16-2006 , 13:14  
Reply With Quote #4

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

+Karma If I helped
MattOG is offline
pixel3
Senior Member
Join Date: Dec 2005
Old 03-16-2006 , 13:15  
Reply With Quote #5

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..
__________________
pixel3 is offline
BAILOPAN
Join Date: Jan 2004
Old 03-16-2006 , 13:16  
Reply With Quote #6

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.
__________________
egg
BAILOPAN is offline
MattOG
Senior Member
Join Date: May 2005
Old 03-16-2006 , 13:17  
Reply With Quote #7

so is my understanding of it, i may be wrong

::edit::

score -1 for me :p
__________________

+Karma If I helped
MattOG is offline
capndurk
Senior Member
Join Date: Feb 2006
Old 03-16-2006 , 14:37  
Reply With Quote #8

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.
capndurk is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:42.


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