Posts: 101
Threads: 30
Joined: May 2009
Reputation:
0
Can you explain me what means that numbers? string[128]; string[256]; and others..;]
Posts: 188
Threads: 24
Joined: Nov 2007
Reputation:
0
Search in wiki about strings. But for example:
"search" has 6 leters, so string will be: string[7];
Posts: 101
Threads: 30
Joined: May 2009
Reputation:
0
Can you tell me that link? Because I can't find it.
Posts: 785
Threads: 22
Joined: Jun 2007
Reputation:
0
When using string[128]; - the variable has 128 cells (not sure) space for characters, that means you can input upto 128 characters into that variable. (Alphabetic characters and numeric characters.)
When using string; - the variable can only be an integer, a number, that means it cannot contain any type of characters.
Posts: 101
Threads: 30
Joined: May 2009
Reputation:
0
So it doesn't matter wich number I would write: 64, 128, 256 and others..?
Posts: 1,293
Threads: 6
Joined: Jul 2008
Reputation:
0
It all depends on the context. If it's a message you'll repeatedly send to a player, you may aswell stick with 128, because that is the output limit. There are very few places you'll need 256, but you're not bounded by binary numbers, so you could have 200 if you wanted. However, if you were just going to store a players name you would use MAX_PLAYER_NAME (Which I think is 24) as anything else would be a waste!
Posts: 2,200
Threads: 14
Joined: Apr 2009
Reputation:
0
And when using strings, always declare the number of cells for one more then the max number you will use: e.g. If you want to save a word with 99 characters, declare a string with 100 cells, because in the last cell there needs to be the "/0" character which basicly marks where the string ends, so the system will know how much to print out. Also, when getting characters out of strings, the cells always start with 0: e.g. if you declare chars[3];, you can only save characters in the cells char[0], char[1] and char[2]