Ç参数不匹配原型 [英] C argument doesn't match prototype

查看:131
本文介绍了Ç参数不匹配原型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从文件中读取并将其插入到密码的我的结构复合变量,但我得到的参数不匹配原型'的错误。

I'm trying to read from a file and insert it into my struct compound variable of 'codon' but I'm getting an error of 'arguments doesn't match prototype'.

下面是我的.C:

#include <math.h>
#include <stdio.h>
#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

我觉得这是一个简单的类型小姐比赛,但我不知道如何解决它。

I feel like it's a simple type miss match but I'm not sure how to fix it.

推荐答案

首先坏点:无效LoadGenetic code(文件名,C){结果
您应指定类型的每个参数。他们被视为 INT 参数,所以它不会匹配的雏形。

First bad point: void LoadGeneticCode(filename, c){
You should specify types of each arguments. They are treated as int arguments and so it won't match the prototype.

第二个坏点: LoadGenetic code('data.dat文件',C);

在字符常量把多个字符'data.dat文件'是不好的。这应该是一个字符串data.dat文件

Putting multiple characters in character constant 'data.dat' isn't good. It should be a string "data.dat".

您应该写你的.c是这样的:

You should write your .c like this:

#include <math.h>
#include <stdio.h>
#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;
}

这篇关于Ç参数不匹配原型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆