1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>

int main(int argc, char* argv[]) {
    uint8_t a[3] = {65, 66, 67};       // initialize array
    uint8_t b[3] = {0x50, 0x51, 0x52};
    char    c    = '9';
    char    d[3] = {'J', 'K', 'L'};
    char*   e    = "XYZ";
    FILE* fp = fopen("file.txt", "w");
    fwrite(a,     sizeof(uint8_t), 2, fp);
    fwrite(b,     sizeof(uint8_t), 2, fp);
    fwrite(&c,    sizeof(char),    1, fp);
    fwrite(d,     sizeof(uint8_t), 2, fp);
    fwrite(e + 1, sizeof(char),    2, fp);
    fclose(fp);
    return EXIT_SUCCESS;
}

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