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
27
28
29
30
31
32
33
34
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char* argv[]) {
    char** daze = malloc(sizeof(*daze) * 4);
    // Array of char*.  Ex:  whatis daze[2] should print char*  (not char)
    // TODO:  What should go in the sizeof(…) operator

    int width = 4;
    for(int i = 0; i < 4; i++) {
        daze[i] = malloc(sizeof(**daze) * width);

        // daze[i] should be an array of char.
        // daze[i][j]  would be a char
        // TODO:  what should you put in sizeof(   )
        // also okay:
        //  sizeof(daze[0][0])
        //  sizeof(daze[999999999][999999999])
    }
    memcpy(daze[0], "**_*", 4);
    memcpy(daze[1], "*_**", 4);
    memcpy(daze[2], "*__*", 4);
    memcpy(daze[3], "*_**", 4);

    for(int i = 0; i < 4; i++) {
        for(int j = 0; j < 4; j++) {
            fputc(daze[i][j], stdout);
        }
        fputc('\n',       stdout);
    }

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

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