/* this program concatenates strings from file1 and file2 and copies them // to resulting file out // usage: katter file1 file2 out */ #include #include void main (int argc, char* argv[]) { FILE *file1, *file2, *out; char *string1 = (char*) malloc (513 * sizeof (char)); char *string2 = (char*) malloc (257 * sizeof (char)); file1 = fopen (argv[1], "r"); file2 = fopen (argv[2], "r"); out = fopen (argv[3], "w"); while (fgets (string1, 256, file1) ) { fgets (string2, 256, file2); strcpy (string1 + strlen (string1) -1, " ") ; strcpy (string1 + strlen (string1), string2); fputs (string1, out); } fclose (file1); fclose (file2); fclose (out); }