printf ("Warning: can not open input file %s\n",argv[this_file]);
/* numc_test.c * * * * * * * * * * * * * * * * * * * * * * * * * * * * \
* *
* FileCat utility to concatenate files together with a catalog *
* Copyright (C) 2016 by Henry Kroll III, www.thenerdshow.com */
#include <stdio.h>
#include <locale.h>
#include <langinfo.h>
#include <string.h>
/* Use any size buffer... */
/* I/O is buffered anyway, so it doesn't matter */
#define buf_MAX 512
int main (int argc, char** argv) {
FILE *f_in, *f_out;
int this_file;
char buf[buf_MAX];
setlocale (LC_CTYPE, "");
if (strcmp(nl_langinfo(CODESET), "UTF-8")) {
fprintf (stderr, "warning: utf-8 filenames not available\n");
} /* argc is always 1 more than what we need... */
argc--;
/* is the number of files correct? */
if (argc > 2) {
/* yes, can we open last file for append in binary mode? */
if ((f_out=fopen(argv[argc],"ab+"))) {
/* yes, let's iterate through each file */
for (this_file=1; this_file < argc; this_file++) {
/* can the file can be opened for reading? */
if ((f_in=fopen(argv[this_file],"rb"))) {
/* yes, read all of f_in and append to f_out */
//fixme: Use fread, fwrite for binary data
while (fgets(buf,buf_MAX,f_in)) {
fprintf (f_out,"%s",buf);
}
/* now close input file */
gcc