Curious Cat
Curious Cat

Reputation: 309

C argument doesn't match prototype

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'.

Here is my .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]);

makefile

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.

Upvotes: 0

Views: 1323

Answers (3)

MikeCAT
MikeCAT

Reputation: 75062

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.

Second bad point: LoadGeneticCode('data.dat', c);

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

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

Upvotes: 3

ameyCU
ameyCU

Reputation: 16607

Your function call in main -

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

Instead try this-

LoadGeneticCode("data.dat", c);

Upvotes: 1

Joker_vD
Joker_vD

Reputation: 3775

In your .c file, try changing

void LoadGeneticCode(filename, c){

to

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

Upvotes: 1

Related Questions