Skip to content

mikiyadd/my-c-array

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

My C Array 📊

C Array
Releases

Welcome to the My C Array repository! This project provides a dynamic array implementation in C, organized in a modular, folder-based structure. This README will guide you through the features, installation, usage, and more.

Table of Contents

  1. Introduction
  2. Features
  3. Installation
  4. Usage
  5. Structure
  6. Examples
  7. Contributing
  8. License
  9. Contact

Introduction

Dynamic arrays are a powerful data structure that can grow or shrink in size as needed. This implementation provides an easy-to-use interface for managing arrays in C. With a focus on modular design, you can easily integrate this into your projects.

For the latest releases, visit Releases. Download the latest version and execute it to get started.

Features

  • Dynamic Resizing: Automatically adjust the size of the array.
  • Modular Design: Organized into folders for easy navigation.
  • Easy Integration: Simple API for adding and removing elements.
  • Memory Management: Handles memory allocation and deallocation efficiently.
  • Cross-Platform: Works with both GCC and Clang compilers.

Installation

To install the My C Array library, follow these steps:

  1. Clone the repository:

    git clone https://github.com/mikiyadd/my-c-array.git
  2. Navigate to the project directory:

    cd my-c-array
  3. Compile the code:

    gcc -o my_c_array src/*.c
  4. Run the program:

    ./my_c_array

For the latest releases, visit Releases. Download the latest version and execute it to get started.

Usage

Using the dynamic array is straightforward. Here’s a simple example:

  1. Include the header file:

    #include "dynamic_array.h"
  2. Create a dynamic array:

    DynamicArray *array = create_dynamic_array();
  3. Add elements:

    add_element(array, 10);
    add_element(array, 20);
  4. Access elements:

    int value = get_element(array, 0); // value will be 10
  5. Clean up:

    free_dynamic_array(array);

Structure

The repository follows a modular structure for easy navigation:

my-c-array/
├── src/
│   ├── dynamic_array.c
│   └── dynamic_array.h
├── examples/
│   └── example.c
└── tests/
    └── test_dynamic_array.c
  • src/: Contains the source code for the dynamic array.
  • examples/: Provides example usage of the library.
  • tests/: Includes test cases to ensure functionality.

Examples

Here are a few examples of how to use the dynamic array:

Example 1: Basic Operations

#include "dynamic_array.h"

int main() {
    DynamicArray *array = create_dynamic_array();

    add_element(array, 1);
    add_element(array, 2);
    add_element(array, 3);

    for (int i = 0; i < array->size; i++) {
        printf("%d\n", get_element(array, i));
    }

    free_dynamic_array(array);
    return 0;
}

Example 2: Resizing the Array

#include "dynamic_array.h"

int main() {
    DynamicArray *array = create_dynamic_array();

    for (int i = 0; i < 100; i++) {
        add_element(array, i);
    }

    printf("Size after adding elements: %d\n", array->size);

    free_dynamic_array(array);
    return 0;
}

Contributing

Contributions are welcome! If you want to improve the library or add features, follow these steps:

  1. Fork the repository.

  2. Create a new branch:

    git checkout -b feature/your-feature-name
  3. Make your changes and commit them:

    git commit -m "Add your message here"
  4. Push to your branch:

    git push origin feature/your-feature-name
  5. Create a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contact

For any questions or feedback, feel free to reach out:

Thank you for checking out My C Array! We hope you find it useful in your projects.