Added file read test

This commit is contained in:
Max Wash
2020-08-24 10:22:59 +01:00
parent 93e7d1f389
commit 7f08e49fb7

24
tests/file.c Normal file
View File

@@ -0,0 +1,24 @@
#include <stdio.h>
int main(int argc, const char **argv)
{
if (argc < 2) {
fprintf(stderr, "Usage: %s <file>\n", argv[0]);
return -1;
}
FILE *fp = fopen(argv[1], "r");
if (!fp) {
fprintf(stderr, "cannot open %s\n", argv[1]);
return -1;
}
char c;
while ((c = fgetc(fp)) != EOF) {
fputc(c, stdout);
}
fflush(stdout);
return 0;
}