0% found this document useful (0 votes)
13 views1 page

Company Operations

The document contains C code for managing a list of companies, including functions to initialize, clean up, and add companies to the list. It also includes a function to display company information. Memory management is handled with dynamic allocation and deallocation.

Uploaded by

susyxhhxusussys
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views1 page

Company Operations

The document contains C code for managing a list of companies, including functions to initialize, clean up, and add companies to the list. It also includes a function to display company information. Memory management is handled with dynamic allocation and deallocation.

Uploaded by

susyxhhxusussys
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#include "company_operations.

h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void initializeCompanyList(struct CompanyList *list) {


list->companies = malloc(MAX_COMPANIES * sizeof(struct CompanyInfo));
if (list->companies == NULL) {
perror("Memory allocation failed");
exit(EXIT_FAILURE);
}
list->size = 0;
}

void cleanupCompanyList(struct CompanyList *list) {


free(list->companies);
list->size = 0;
}

bool addCompany(struct CompanyList *list, const struct CompanyInfo *company) {


if (list->size >= MAX_COMPANIES) {
printf("Pasiektas imoniu limitas.\n");
return false;
}
list->companies[list->size++] = *company;
return true;
}

void displayCompany(const struct CompanyInfo *company, int index) {


printf("Imone %d\n", index);
printf("Pavadinimas: %s\n", company->companyName);
printf("Imones kodas: %s\n", company->companyCode);
printf("Imones adresas: %s\n", company->companyAddress);
printf("Imones ikurimo metai: %s\n", company->establishmentYear);
}

You might also like