Back to Skills

c-data-structures

verified

Use when implementing data structures in C including arrays, linked lists, trees, and hash tables with manual memory management.

View on GitHub

Marketplace

han

TheBushidoCollective/han

Plugin

jutsu-c

Technique

Repository

TheBushidoCollective/han
60stars

jutsu/jutsu-c/skills/c-data-structures/SKILL.md

Last Verified

January 24, 2026

Install Skill

Select agents to install to:

Scope:
npx add-skill https://github.com/TheBushidoCollective/han/blob/main/jutsu/jutsu-c/skills/c-data-structures/SKILL.md -a claude-code --skill c-data-structures

Installation paths:

Claude
.claude/skills/c-data-structures/
Powered by add-skill CLI

Instructions

# C Data Structures

Master implementing fundamental and advanced data structures in C with
proper memory management, including arrays, linked lists, trees, hash
tables, and more.

## Arrays and Pointers

### Static Arrays

```c
#include <stdio.h>

void print_array(int arr[], size_t size) {
    for (size_t i = 0; i < size; i++) {
        printf("%d ", arr[i]);
    }
    printf("\n");
}

int main(void) {
    int numbers[5] = {10, 20, 30, 40, 50};

    printf("Array size: %zu bytes\n", sizeof(numbers));
    printf("Element size: %zu bytes\n", sizeof(numbers[0]));
    printf("Number of elements: %zu\n", sizeof(numbers) / sizeof(numbers[0]));

    print_array(numbers, 5);

    // Array indexing is pointer arithmetic
    printf("numbers[2] = %d\n", numbers[2]);
    printf("*(numbers + 2) = %d\n", *(numbers + 2));

    return 0;
}
```

### Dynamic Arrays

```c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct {
    int *data;
    size_t size;
    size_t capacity;
} DynamicArray;

DynamicArray *array_create(size_t initial_capacity) {
    DynamicArray *arr = malloc(sizeof(DynamicArray));
    if (!arr) return NULL;

    arr->data = malloc(initial_capacity * sizeof(int));
    if (!arr->data) {
        free(arr);
        return NULL;
    }

    arr->size = 0;
    arr->capacity = initial_capacity;
    return arr;
}

int array_push(DynamicArray *arr, int value) {
    if (arr->size >= arr->capacity) {
        size_t new_capacity = arr->capacity * 2;
        int *new_data = realloc(arr->data, new_capacity * sizeof(int));
        if (!new_data) return -1;

        arr->data = new_data;
        arr->capacity = new_capacity;
    }

    arr->data[arr->size++] = value;
    return 0;
}

int array_get(DynamicArray *arr, size_t index) {
    if (index >= arr->size) {
        fprintf(stderr, "Index out of bounds\n");
        return -1;
    }
    return arr->data[index];
}

void array_free(DynamicArray *arr) {
    if (arr) {
        free(arr->data);
        free(arr)

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
20630 chars