Help Understanding Array Lenght
#1

Hello People
I have recently Started Coding.
So I Really Wanted to Know what array lenght Shall be chosen for the UserName Field.

And
How Does Higher lenghts Affect the processing of code?
Reply
#2

The Array Length Should be 24
As it is the Maximum Characters allowed in a name.
Reply
#3

But isn't the max player name of 20 characters?
Then why is the length 24?
Reply
#4

The MaxPlayerName is 24
Reply
#5

Quote:
Originally Posted by iSteve
Посмотреть сообщение
Hello People
I have recently Started Coding.
So I Really Wanted to Know what array lenght Shall be chosen for the UserName Field.

And
How Does Higher lenghts Affect the processing of code?
Higher lengths - more cells allotted, and more memory is wasted. (Imagine you need only 128 chairs for a party with 128 or less people, but you instead set up 1024 chairs. So much space wastage!)

Quote:
Originally Posted by iSteve
Посмотреть сообщение
But isn't the max player name of 20 characters?
Then why is the length 24?
The length was 20, it was increased to 24, IIRC.
Reply
#6

Ok thanks Rajat!
Can I conclude that every character I need to use requires 1 array length?
Reply
#7

Kind of, yes. There is no actual string datatype in PAWN unlike some other languages, you must use arrays for that purpose.

Check out the below example, I've used 3 different methods to print the same character. (a)
There may be more.

pawn Код:
new c = 97,  // ASCII code for 'a'

         a[1] = 'a',    // Direct array assignment

         holder = 'a';  // Direct

main() {

printf("%c", c);
printf("%c", a);
printf("%c", holder);

}
If you don't know what %c does in printf, check this page out. It is a specifier for printing characters.
Reply
#8

Thanks for this
And yea I know about specifiers ... That was one of the computer classes I hadn't bunked

Thanks for the help guys
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)