I am trying to set up an array of structs that will eventually print off 6 boxes using ncurses. First problem is i dont know how to set up an array of structs, and my second problem is, i dont know how im supposed to draw the boxes. An extra thing about the boxes is that they must be drawn using the "|" key for the vertical walls, and i need to use "-" for the walls going horizontally. I have tried to malloc memory for an array of structs using:
room * roomInfo = malloc(sizeof(room) * 6);
with room being my struct name and roomInfo being my array of structs. I am getting three errors with this. One is "error: unknown type name 'room'" and the other is "error: 'room' undeclared (first use in this function)" (at the top of my file i have: "struct room roomInfo;") and the third being "note: each undeclared identifier is reported only once for each function it appears in"
typedef struct
{
int roomNumber;
int height;
int width;
int eastDoor;
int westDoor;
int southDoor;
int northDoor;
}room;
Not sure what you are doing wrong: the following minimal code compiles without errors:
Most likely: your definition of
room
is not known at the time that you declareroom *roomInfo;
. Is it in a#include
?