Added file read test
This commit is contained in:
24
tests/file.c
Normal file
24
tests/file.c
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user