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

typedef unsigned char uchar;

void write_file(char const* filename, uchar const* contents) {
    FILE* fp = fopen(filename, "w");
    for(int i = 0; contents[i] != '\0'; i++) {
        uchar char_to_write = contents[i];
        fputc(char_to_write, fp);  // write one character
    }
    fclose(fp);
}

int main(int argc, char* argv[]) {
    uchar const contents[] = { '\xde', '\xca', '\xf0', 'B' };
    write_file("quiz4.txt", contents);
    return EXIT_SUCCESS;
}

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