Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3315892
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:24:16+00:00 2026-05-17T22:24:16+00:00

My program takes two files with words sorted as parameter and performs the mixture

  • 0

My program takes two files with words sorted as parameter and performs the mixture into 1 single file called final_sorted.txt.the program runs successfully and creates the mixed file, even ignoring repeated words, but the compiler tells me some warnings that are not as removed.

equipo01@equipo01-desktop:~/Escritorio/mezclar (2)$ gcc meclapro.c -o mixmeclapro.c: In function ‘mix_files’:
meclapro.c:10: warning: passing argument 1 of ‘fopen’ from incompatible pointer type
/usr/include/stdio.h:249: note: expected ‘const char * __restrict__’ but argument is of type ‘char **’
meclapro.c:11: warning: passing argument 1 of ‘fopen’ from incompatible pointer type
/usr/include/stdio.h:249: note: expected ‘const char * __restrict__’ but argument is of type ‘char **’
meclapro.c: In function ‘main’:
meclapro.c:69: warning: passing argument 1 of ‘mix_files’ from incompatible pointer type
meclapro.c:6: note: expected ‘char **’ but argument is of type ‘char *’
meclapro.c:69: warning: passing argument 2 of ‘mix_files’ from incompatible pointer type
meclapro.c:6: note: expected ‘char **’ but argument is of type ‘char *’

this is my code, which takes which takes the command line parameter

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

void mix_files(char **file1, char **file2){

    FILE *a1, *a2, *output;
    char aux1 [10000],aux2 [10000];
    a1 = fopen(file1, "r");
    a2 = fopen(file2, "r");
    ouput =  fopen ("final.txt", "w+");

    // read the first line of each file:
    fscanf(a1,"%s",aux1);
    fscanf(a2,"%s",aux2); 
    // loop, while !feof for both file
    while(!feof(a1) && !feof(a2)) {
        // Select the line to add
        if(strcasecmp(aux1,aux2) < 0){
            // add the line
            fprintf(output,"%s\n",aux2);
            //read the next line from aux2
            fscanf(a2,"%s",aux2);
        }

        else if(strcasecmp(aux1,aux2)>0){
            fprintf(salida,"%s\n",aux1);
            fscanf(a1,"%s",aux1);
        }

        if (strcasecmp(aux1,aux2)==0){ 
            //printf("repetidas\n");
            fprintf(salida,"%s\n",aux1);
            fscanf(a1,"%s",aux1);   
            fscanf(a2,"%s",aux2);
        }
    }

    if(!feof(a1)){
        while(!feof(a1)) {
            fscanf(a1,"%s",aux1);
            fprintf(salida,"%s\n",aux1);
        }
    }
    if(!feof(a2)){
        while(!feof(a2)) {
            fscanf(a2,"%s",aux2);
            fprintf(salida,"%s\n",aux2);
        }
    }

}

int main(int argc, char *argv[]){

    mix_files(argv[2], argv[1]);

    return(0);
}

I would like someone to help me discover the reason for the warning and how could I fix, thanks in advance for your answers, sorry for my English

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T22:24:16+00:00Added an answer on May 17, 2026 at 10:24 pm

    Change:

    void mix_files(char **file1, char **file2){
    

    to:

    void mix_files(char *file1, char *file2){
    

    or better still:

    void mix_files(const char *file1, const char *file2){
    

    You will then be passing the correct type (char *) from main to mix_files, and this in turn will also fix the problem when you call fopen.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Now my program generates two data files. a.txt and b.txt Take a.txt as an
I have a java program that generates an HTML file. The Java program takes
Some loading routines in my program takes to long to complete. I want a
I recently inherited a small Java program that takes information from a large database,
I am trying to write a C++ program that takes the following inputs from
I'm curious about what it takes to program for mobile devices (Windows Mobile 6.1)
If something is making a single-thread program take, say, 10 times as long as
My program will take arbitrary strings from the internet and use them for file
I'm trying to do this: cmd.exe /C C:\Program Files\Somewhere\SomeProgram.exe > C:\temp\Folder Containing Spaces\SomeProgram.out However,
The program needs to take in a simple string from the user and display

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.