C参数与原型不匹配

我正在尝试从文件中读取并将其插入到’密码子’的struct复合变量中,但我收到的错误是’参数与原型不匹配’。

这是我的.c:

#include  #include  #include "genome.h" void LoadGeneticCode(filename, c){ FILE *file = fopen(filename, "r"); } int main() { codon c[64]; //making array of c LoadGeneticCode('data.dat', c); return 0; } 

。H

 typedef struct { char b1,b2,b3; int a;} codon; void LoadGeneticCode(char *filename, codon c[64]); 

生成文件

 HEADERS = genome.h default: genome genome.o: genome.c $(HEADERS) gcc -c genome.c -o genome.o genome: genome.o gcc genome.o -o genome clean: -rm -f genome.o -rm -f genome 

我觉得这是一个简单的类型未命中匹配,但我不知道如何解决它。

第一个void LoadGeneticCode(filename, c){void LoadGeneticCode(filename, c){
您应该指定每个参数的类型。 它们被视为int参数,因此它与原型不匹配。

第二个LoadGeneticCode('data.dat', c);LoadGeneticCode('data.dat', c);

在字符常量'data.dat'放置多个字符并不好。 它应该是一个字符串"data.dat"

你应该像这样写你的.c:

 #include  #include  #include "genome.h" void LoadGeneticCode(char *filename, codon c[64]){ FILE *file = fopen(filename, "r"); } int main(void) { codon c[64]; //making array of c LoadGeneticCode("data.dat", c); return 0; } 

.c文件中,尝试更改

 void LoadGeneticCode(filename, c){ 

 void LoadGeneticCode(char *filename, codon c[64]){ 

你的函数调用main

 LoadGeneticCode('data.dat', c); // string literals should be in double quotes 

相反,试试这个 –

 LoadGeneticCode("data.dat", c);