1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <assert.h>

void print_strings(char* label, char** strings, size_t num_strings) {
    printf("\n──────────────────────────────\n");
    printf("%s\n", label);
    for(int i = 0; i < num_strings; i++) {
        printf("%s\n", strings[i]);
    }
    printf("\n");
}

int main(int argc, char* argv[]) {
    char* strings[] = { "charie", "bravo", "echo", "delta", "alpha" };
    size_t size_of_one = sizeof(strings[0]);
    printf("size_of_one == %zd\n", size_of_one);
    printf("sizeof(strings) == %zd\n", sizeof(strings));
    size_t num_elements = sizeof(strings) / sizeof(strings[0]); // for static arrays ONLY

    print_strings("STRINGS", strings, num_elements);

    return EXIT_SUCCESS;
}
/* vim: set tabstop=4 shiftwidth=4 fileencoding=utf-8 noexpandtab: */

© Copyright 2021 Alexander J. Quinn         This content is protected and may not be shared, uploaded, or distributed.