retroforth/tools/tanu.c
crc ae0732e5cd begin moving tools
FossilOrigin-Name: baac9ff86fe6db99066d01dd322d6c3291c513d0d8d447643e99f28cbe1a0d6b
2017-10-19 19:06:21 +00:00

35 lines
687 B
C

/* ____ ____ ______ ____ ___
|| \\ || | || | || \\ // \\
||_// ||== || ||_// (( ))
|| \\ ||___ || || \\ \\_//
a personal, minimalistic forth
This converts a text file into a C character array.
Copyright (c) 2016, 2017 Charles Childers
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
void include_file(char *fname) {
int ch;
FILE *fp;
fp = fopen(fname, "r");
if (fp == NULL)
return;
while (!feof(fp)) {
ch = getc(fp);
printf("%d, ", ch);
}
fclose(fp);
}
int main(int argc, char **argv) {
printf("char %s[] = {", argv[1]);
include_file("/dev/stdin");
printf("0 };\n");
}