Help navigating through array.
#1


Why is it outputting random numbers instead of what's in the array? I've never worked with arrays until now.
Reply
#2

pawn Код:
gArray[][]={
{"Ganton", 1 ,2 ,3},
//...
What did you actually do?
pawn Код:
gArray[0][0]='G';
gArray[0][1]='a';
gArray[0][2]='n';
gArray[0][3]='t';
gArray[0][4]='o';
gArray[0][5]='n';
gArray[0][6]='\0'; // same as gArray[0][7]= 0
gArray[0][7]='1';
gArray[0][8]='2';
gArray[0][9]='3';
Do you get it now?
pawn Код:
printf("%s",gArray[0][0])//will print the string from place gArray[0][0] to the last place where it sees '\0'
printf("%i",gArray[0][0])// this will print Iniger value of a char( form ascii table)
so printf("%i",gArray[0][1]) will put out Intiger value of 'a' which is 97
Reply
#3

I get it, arrays have always been a grey area for me.

I was trying to make an array that holds fire info, the name, and location. I'll just use the array for co-ordinates, and use the zone script to get the location name.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)