linux 从不兼容的指针类型,警告从不兼容的指针类型传递'fopen'的参数1

我的程序需要两个文件,并将单词排序为参数,并将混合文件执行成一个单独的文件,称为final_sorted.txt。程序成功运行并创建混合文件,甚至忽略重复的单词,但是编译器告诉我一些警告并没有被删除。警告从不兼容的指针类型传递'fopen'的参数1

[email protected]:~/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 *’

这是我的代码,这需要这需要在命令行参数

#include

#include

#include

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);

}

我想有人帮助我发现了警告的原因,我怎么能解决,在此先感谢您的回答,对不起我的英语

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值