mirror of
https://git.sr.ht/~crc_/retroforth
synced 2024-11-16 19:48:56 +01:00
183c5bae38
FossilOrigin-Name: d2b8467883db80cb179089e1db1b1ed4dff1f11b4bee7086ee46d83f3ee0136e
35 lines
687 B
C
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");
|
|
}
|