Okay, not sure if I'm still a bit off.. but... I think I have roughly the right idea now.. I really have been doing C for about a week and I'm really confused by it having learnt other languages, which are very different (such as Haskell).
Code:
#include <stdio.h>
int main(int argc, char *argv[])
{
// check num of args
if(argc < 3)
{
fprintf(stderr,"error: not enough arguments\n")
}
else
{
FILE *fileOne =fopen( argv[1], "r");
FILE *fileTwo =fopen( argv[2], "r");
char sep = argv[0]
char LineA[512]
char LineB[256]
if ( fileOne == 0 | fileTwo == 0)
{
/* error*/
fprintf(stderr, "Error: Can't open file: %d: %s\n", errno, strerror(errno))
}
else
{
int x;
while( (x fgets(LineA,100, fileOne) && fgets(LineB,100, fileTwo) ) !=EOF)
{
strcat(LineA, sep);
strcat(LineA, LineB);
}
}
}
return;
}
What I THINK this should be doing is while it isn't at the end of file a or b keep going and reading in the next line,
then add the line sep to file a, then add the next line from b.. possibly need to just give LineB instead of fgets on the 2nd while thing.. and add some {'s.. >.<