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.
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.
- 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.
To install the My C Array library, follow these steps:
-
Clone the repository:
git clone https://github.com/mikiyadd/my-c-array.git
-
Navigate to the project directory:
cd my-c-array -
Compile the code:
gcc -o my_c_array src/*.c -
Run the program:
./my_c_array
For the latest releases, visit Releases. Download the latest version and execute it to get started.
Using the dynamic array is straightforward. Hereβs a simple example:
-
Include the header file:
#include "dynamic_array.h"
-
Create a dynamic array:
DynamicArray *array = create_dynamic_array();
-
Add elements:
add_element(array, 10); add_element(array, 20);
-
Access elements:
int value = get_element(array, 0); // value will be 10
-
Clean up:
free_dynamic_array(array);
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.
Here are a few examples of how to use the dynamic array:
#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; }#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; }Contributions are welcome! If you want to improve the library or add features, follow these steps:
-
Fork the repository.
-
Create a new branch:
git checkout -b feature/your-feature-name
-
Make your changes and commit them:
git commit -m "Add your message here" -
Push to your branch:
git push origin feature/your-feature-name
-
Create a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
For any questions or feedback, feel free to reach out:
- Email: your_email@example.com
- GitHub: mikiyadd
Thank you for checking out My C Array! We hope you find it useful in your projects.