Array to string
#8

You can't store several pieces of data in a variable, that's why we use arrays for containing words.
Each variable can store 1 piece of data.
pawn Код:
Var1 = "H";
Var2 = "i";
You cannot do
pawn Код:
Var = "Hi";
It's the same with arrays, but they're like several variables.
You could say using Array[3] contains 3 "variables".
pawn Код:
Array[0] = "H";
Array[1] = "i";
Array[2] = "\0";
Which is the same as just doing
pawn Код:
Array = "Hi";
If the array is declared using
pawn Код:
new Array[3];
Because each "number" is like 1 variable, so here we have 3 variables, which and can store 1 piece of information each.
The reason we need 3 is because of the null constant, AKA "\0", it tells the compiler that the string ends where the null symbol is.
You can read more in this tutorial:
https://sampforum.blast.hk/showthread.php?tid=318212
Reply


Messages In This Thread
Array to string - by Sickae - 01.04.2015, 16:19
Re: Array to string - by CalvinC - 01.04.2015, 16:41
Re: Array to string - by Sickae - 01.04.2015, 16:49
Re: Array to string - by iggy1 - 01.04.2015, 16:53
Re: Array to string - by admantis - 01.04.2015, 16:56
Respuesta: Array to string - by alexus - 01.04.2015, 17:02
Re: Respuesta: Array to string - by Yashas - 01.04.2015, 17:12
Re: Array to string - by CalvinC - 01.04.2015, 17:20
Re : Array to string - by nicolaskettler - 01.04.2015, 17:38
Re: Respuesta: Array to string - by Sickae - 01.04.2015, 18:15

Forum Jump:


Users browsing this thread: 2 Guest(s)