View Single Post
Doggg
Member
Join Date: Jun 2018
Old 07-09-2019 , 16:49   Re: how can you scan a variable and then apply it?
Reply With Quote #14

Quote:
Originally Posted by Whai View Post
Well,

char value[4] is an array of char (char is the abbreviation of characters) with the size of 4 but there is an exception only on arrays of char.

First, index of arrays go from 0 to the size - 1, that means if you create an array with the size of 4 (meaning you'll have 4 places to store item) : it will go from 0 to 3.
However, on arrays of char (in sourcemod or maybe others programming languages) the last index is reserved to place the "\0" --> it means the end of the "word".

By creating an array of char with the length of 4, you will have 3 free places.

In conclusion, yes : if you write "15" you need at least 2 free places.

Note : I wrote all of this to make this for you understand roughly speaking how works array in SM
Thanks for the time you put into this, I knew most of this, It is very similar to C (at least i think it is) you have any idea why the guy here put 32 in the code? 32 looks bit too much for me. i mean i think the max is going to be 5 (this is means i can put up to 1000 right?, 4 free spaces.

Last edited by Doggg; 07-09-2019 at 16:53.
Doggg is offline