add changes to sqlite_ex and some new files
This commit is contained in:
33
cat_v2.c
Normal file
33
cat_v2.c
Normal file
@ -0,0 +1,33 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void filecopy(FILE *, FILE *);
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
FILE *file_p;
|
||||
char *prog_name = argv[0];
|
||||
|
||||
if (argc == 1)
|
||||
filecopy(stdin, stdout);
|
||||
else
|
||||
while (--argc > 0)
|
||||
if ((file_p = fopen(*++argv, "r")) == NULL) {
|
||||
fprintf(stderr, "%s: can't open: %s\n", prog_name, *argv);
|
||||
exit(1);
|
||||
} else {
|
||||
filecopy(file_p, stdout);
|
||||
fclose(file_p);
|
||||
}
|
||||
if (ferror(stdout)) {
|
||||
fprintf(stderr, "%s: error writing stdout\n", prog_name);
|
||||
exit(2);
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void filecopy(FILE *in_file_p, FILE *out_file_p) {
|
||||
int ch;
|
||||
|
||||
while ((ch = getc(in_file_p)) != EOF)
|
||||
putc(ch, out_file_p);
|
||||
}
|
Reference in New Issue
Block a user