New to C : combining lines in text files
Hi,
I'm really new to C and I've been doing some exercises to get to grips with it. I am learning about file I/O atm, and I've read the through the tutorial on this website.
e.g.
separator string is '--' fileOne contains fst line : hello fileTwo contains fst line : world
my program aims to print "hello--world"
So yeah any pointers (pardon the pun) or links to tutorials would be great too.
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");
if ( fileOne == 0 | fileTwo == 0)
{
/* error*/
fprintf(stderr, "Error: Can't open file: %d: %s\n", errno, strerror(errno))
}
else
{
int x;
while ( ( x fgetc ( fileOne ) ) !=EOF )
{
//not sure what to do..
}
}
}
return;
}
Thanks for any help/advice in advance!