I'm getting "expected initializer before 'read_file' as an error. The error is on the line "instruction code[] read_file(instruction code[])." Its on line Been searching the web for help, all im finding is c++ related post, so to clarify this is for C.
I've tried moving around the positioning of the function protypes. I wrote the same program earlier that implemented linked list instead of an array and I had no errors, so I'm thinking it may have something to do with the structure array.
Thanks for the help.
#include<stdio.h>
#include <stdlib.h>
typedef struct instruction{
int op; //opcode
int l; // L
int m; // M
} instr;
FILE * ifp; //input file pointer
FILE * ofp; //output file pointer
instruction code[501];
instruction code[] read_file(instruction code[]);
char* lookup_OP(int OP);
void print_program(instruction code[]);
void print_input_list(instruction code[]);
int main(){
code = read_file(code);
print_input_list(code);//used for debugging
print_program(code);
}
instruction code[] read_file(instruction code[]){
int i = 0;
ifp = fopen("input.txt", "r");
while(!feof(ifp)){
fscanf(ifp,"%d%d%d",&code[i]->op, &code[i]->l, &code[i]->m);
i++;
}
code[i]->op = -1; //identifies the end of the code in the array
fclose(ifp);
return code;
}