Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
FileCat
/* 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 */ fclose (f_in); } /* no, print a warning if file did not open */ else { printf ("Warning: can not open input file %s\n",argv[this_file]); } } /* no, close output file */ fclose (f_out); } /* no, print a warning */ else { printf ("can not open output file %s\n",argv[argc]); return 1; } } /* no, print usage instructions */ else { printf ("usage fcat: file1 file2 ... outfile\n"); } return 0; }
run
|
edit
|
history
|
help
0
Score
menu
Program to calculate characters
prime numbers using functions
Euclides MIRAR
-Wall
swap_talent.c
PUNTEROS 1
Stub Program for Problem 4 HW 2
18BCE2182 ASSESS_2 Q-1