'File lines concatenation

i have a method that is supposed to print file lines concatenated with other file lines, basically what i wanted to is is that if we have a file1 with this data

111100000
111001000
111000100

and file2 with this data

0

it supposed to returns 1+file1_lines+file2_lines so for this one it should returns

11111000000
11110010000
11110001000

Here is what I tried to do so far:

#include <stdio.h>
#include <stdlib.h>
#define TAILLE_MAX 10000


void assemblage_fichier(const char *file1, const char *file2){
    FILE *fichier1, *fichier2;
    fichier1 = fopen(file1, "r");
    fichier2 = fopen(file2, "r");
    char c[TAILLE_MAX], c2[TAILLE_MAX];
    
    if(!fichier1 || !fichier2){
        printf("cannot open file \n");
        exit(0);
    }
    
    while (fgets(c, sizeof(c), fichier1) && fgets(c2, sizeof(c2), fichier2))
    {
        printf("1%s%s\n", c, c2);
    }
    
    fclose(fichier1);
    fclose(fichier2);
}


int main(int argc, char const *argv[])
{
    assemblage_fichier(argv[1], argv[2]);
    return 0;
}

by the way my code returns:

11111000000

so it does the job for only one line.

c


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source