Inserting a string variable into an array (ERROR 006)
#2

That is simply not possible. Strings are stored in arrays; each character is an index.

pawn Код:
new string[6] = "Hello";

string[0] = 'H';
string[1] = 'e';
string[2] = 'l';
string[3] = 'l';
string[4] = 'o';
string[5] = 0; // Null terminator (can be represented with '\0')
If you want an array of strings, you have to do something like this:

pawn Код:
new strings[5][16] = { // 5 strings with UP TO 15 characters each (+1 for null terminator)
"example",
"example",
"example",
"example",
"example"
};
Then you could display the first string as 'strings[0]. But even then you can't use the assignment operator (x = y) to modify an array unless it is the same size. You'd have to use format().
Reply


Messages In This Thread
Inserting a string variable into an array (ERROR 006) - by Mironinja4 - 15.04.2015, 18:43
Re: Inserting a string variable into an array (ERROR 006) - by MP2 - 15.04.2015, 19:06
Re: Inserting a string variable into an array (ERROR 006) - by Crayder - 15.04.2015, 20:47
Re: Inserting a string variable into an array (ERROR 006) - by Mironinja4 - 16.04.2015, 06:48
Re: Inserting a string variable into an array (ERROR 006) - by Crayder - 16.04.2015, 11:05

Forum Jump:


Users browsing this thread: 1 Guest(s)