C > Gnu-Linux
Appending two files
Appending two files #include
#include
#include
#include
#include
int main(int argc, char **argv) { char buf[1024]; int n, in, out; if(argc != 3) { fprintf(stderr, "Usage: append SOURCE TARGET\n"); return 0; } /* open the first file for reading */ in = open(argv[1], O_RDONLY); /* the second file for writing */ out = open(argv[2], O_WRONLY|O_APPEND); /* copy data from the first file to the second file */ while((n = read(in, buf, sizeof(buf))) > 0) write(out, buf, n); return 0; }
C Codes
Beginners
C on Unix
Code Snippets
Data Structures
File Operations
Games Graphics
Gnu-Linux
Hardware
Mathematics
Miscellaneous
Small Programs
Sorting