Array of structure
-
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!