I am trying to get input from two txt files (line by line) and output the two files side by side in colums 38 characters wide. Output should go to a single txt file.
I have been able to get the input by line and have it output it as follows:
line 1 txt file 1
line 1 txt file 2
line 2 txt file 1
line 2 txt file 2
ect.
What Im trying to get is:
line 1 (truncated to 38 char) "space space" line 1 (truncated 38 char)
line 2 (truncated to 38 char) "space space" line 2 (truncated 38 char)
I am stuck and can't seem to get any further. Here is my code:
Code:
#include <stdio.h>
#include <string.h>
#define MAX 1000
int main(int argc, char **argv)
{
char *Path1 = "C:\\Documents and Settings\\Brad\\My Documents\\Visual Studio 2010\\Projects\\Assignment 10\\GettysburgAddress.txt";
char *Path2 = "C:\\Documents and Settings\\Brad\\My Documents\\Visual Studio 2010\\Projects\\Assignment 10\\Anthem.txt";
char *Path3 = "C:\\Documents and Settings\\Brad\\My Documents\\Visual Studio 2010\\Projects\\Assignment 10\\output.txt";
FILE *Getty, *National, *output;
char line[MAX];
char line2[MAX];
char outputline[1000];
Getty = fopen(Path1, "r");
if (!Getty)
return 1;
National = fopen(Path2, "r");
if (!National)
return 1;
output = fopen(Path3, "w");
if (!output)
return 1;
while (fgets(line,(MAX),Getty))
{
fputs(line, output);
fgets(line2,(MAX),National);
//strcat(line, line2);
fputs(line2, output);
}
fclose (Getty);
fclose (National);
fclose (output);
getchar();
return 0;
}