Organization Assignment in C programming


Joined
Sep 7, 2022
Messages
1
Reaction score
0
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;
 

Attachments

  • Organization (1).pdf
    200.4 KB · Views: 0
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top