mirror of
https://github.com/cc65/cc65.git
synced 2024-11-12 07:07:19 +00:00
1a5a7d67a7
-36 bytes, -12% cycles
40 lines
631 B
C
40 lines
631 B
C
/*
|
|
!!DESCRIPTION!! fgets test
|
|
!!LICENCE!! Public domain
|
|
*/
|
|
|
|
#include "common.h"
|
|
|
|
#include <ctype.h>
|
|
#include <errno.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <unistd.h>
|
|
|
|
FILE *in, *out;
|
|
int c, err;
|
|
|
|
#define INFILE "cf.in"
|
|
|
|
int main(int argc,char **argv)
|
|
{
|
|
in = fopen(INFILE, "rb");
|
|
if (in == NULL) {
|
|
return EXIT_FAILURE;
|
|
}
|
|
|
|
if (fputc(c, in) != EOF) {
|
|
printf("Error: can fputc to a file opened for reading\n");
|
|
return EXIT_FAILURE;
|
|
}
|
|
clearerr(in);
|
|
|
|
while ((c = fgetc(in)) != EOF) {
|
|
fputc(c, stdout);
|
|
}
|
|
|
|
fclose(in);
|
|
return 0;
|
|
}
|