Hello, I have a lot of trouble with the assignment. It has to do with structs and memory allocation. I have some code so far and I'm wondering what I did wrong.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ANIMAL_SIZE 1000
struct Cage
{
char animal[ANIMAL_SIZE + 1];
Cage*cages;
cages = (Cages *)calloc( cageCount, sizeof(Cage))
};
struct Cage {
char animal[1000];
unsigned count;
struct Cagetype* next;
} Cage;
struct Sectiontype {
Cage*cages;
unsigned numCages;
struct Sectiontype* next;
} Section;
struct {
typedef struct Section* sections;
unsigned numSections;
} Zoo;
Section* CreateSection();
// main function
int main() {
Zoo zoo = {NULL, 0};
// add Animal Stock (Section 0)
zoo.sections = CreateSection();
zoo.numSections++;
}
return 0;
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ANIMAL_SIZE 1000
struct Cage
{
char animal[ANIMAL_SIZE + 1];
Cage*cages;
cages = (Cages *)calloc( cageCount, sizeof(Cage))
};
struct Cage {
char animal[1000];
unsigned count;
struct Cagetype* next;
} Cage;
struct Sectiontype {
Cage*cages;
unsigned numCages;
struct Sectiontype* next;
} Section;
struct {
typedef struct Section* sections;
unsigned numSections;
} Zoo;
Section* CreateSection();
// main function
int main() {
Zoo zoo = {NULL, 0};
// add Animal Stock (Section 0)
zoo.sections = CreateSection();
zoo.numSections++;
}
return 0;