Array of structure
-
Hello
I am French , sorry for my english
I want to make a array of two dimensions of structure ( 2 , 10) for a adventure game.
I dont know , if it is possible and I dont know the syntax.Struct TypeRoom
int north ,
int south ,
int west ,
int south ,
string description
EndstructTypeRoom Room
array Room [ 2 ] [ 10 ]
Room [0] [ 5] .North = 1 for example
I want to know the correct syntax.
Thank.
-
Someone correct me if I'm wrong, but I think the syntax should be:
TypeRoom Room[2][10] -
@Nisse5 said in Array of structure:
Someone correct me if I'm wrong, but I think the syntax should be:
TypeRoom Room[2][10]Thatโs exactly how I do it ๐๐ป
-
Thanks, but i have problems again.
Struct TypeRoom
int north
int south
int west
int south
string description
EndstructTypeRoom Room [2] [10] // OK
room [0] [0].north = 1 // OK
int x
x = room [0] [0].north // KOI have this errror message with this line
=> LINE 7
FUNCTION N/AUNRECOGNIZED TYPE : 4
-
It may be a scoping issue. Is room declared as a global or near start after endstruct? If it was created in a function or loop, its only usable in that function or loop
-
This is gonna sound silly, but you have a string in your Struct youโre not using. And Iโve found this will cause an error even though youโre not actually using it.
So, try assigning a value to your unused string โdescriptionโ, anything, even if only =โโ and it ought to work. (or delete the string for now)
-
@Jongjungbu Sounds like a bug. Have you reported that one?
-
@pianofire Of course not. I never report any bugs even though I should be. ๐ฑ๐
-
THANK YOU VERY MUCH Jongjungbu, you have found my bug.
You are a good programmer.
I think in fuze basic in a array of structure we must initialize all fields of the structure .
My mistake was to declare 20 structure ( TypeRoom Room [2] [10] ) and initiliaze only one for testing.
I have changed my code in TypeRoom Room [0] [0] , declaring one structure and initialize one structure . It's work
After I have changed my code in TypeRoom Room [2] [2] , declaring 4 structure and initialize 4 structure . It's work -
I will raise this as an issue
-
@pianofire it counts that I reported a bug now? ๐
@Thierry Glad that worked out for you, and thanks for the compliment!