mahdi_2

Hi guys I was having issues with reading 3 files and merging them into an array, I tried fgetc, which then let me to have issues with sorting them so I tried to change my array and allocate a counter variable to get the size of it but not sure which method would be best to read and insert into an arrat I tried a few ways which I commented below, however I get errors for both. I'm a bit lost when it comes to arrays and pointers. any help is appriciated. :)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    printf("test 1\n");
    //open three files for merging
    FILE *fp1 = fopen("american0.txt","r");
    FILE *fp2 = fopen("american1.txt","r");
    FILE *fp3 = fopen("american2.txt","r");

    //open file to store the result
    FILE *fpm = fopen("words.txt", "w");

    //creating an array to save the files data
    char *c;
    int i, j;
    int count;
    char mergedFile[count][50];
    //creating a second array as a temp value for sorting purposes
    char temp[50];
    printf("test 2\n");
    //checking to make sure files are being read
    if(fp1 == NULL || fp2 == NULL || fp3 == NULL || fpm == NULL)
    {
        printf("Could not open one or all of the files.\n");
        printf("Exiting program!");
        exit(0);
    }

    printf("test 3\n");
    //inserting data from file into an array
    while ((fgets(c, 50 ,fp1))!= EOF) //tried this failed
    {
        mergedFile[i++]=c;
        count++;
    }
    while ((c = fscanf(fp2)) != EOF) //also with fscanf failed as well
    {
        mergedFile[i++]=c;
        count++;
    }
    while ((c = fscanf(fp3)) != EOF)
    {
        mergedFile[i++]=c;
        count++;
    }

    printf("test 4\n"); ...