So I have a structure like this:
struct state {
int previous[2];
int current[2];
bool pen;
};
typedef struct state state;
In a few functions I used this as an argument, for example:
void new_state(&s, char *file, int i, int j){
int new = s -> current[j];
s -> current[j] = operand(byte(i, file)) + s -> current[j];
s -> previous[j] = new;
}
I call these in a function, where I define s as being from state:
void main_function(char *file){
state s;
display *display = newDisplay(file, 200, 200);
int j = size(file);
for(int i=0; i<j; i++){
if(opcode(byte(i, file)) == 0){
new_state(&s, file, i, 0);
}
else if(opcode(byte(i, file)) == 1){
new_state(&s, file, i, 1);
draw(s, display, file);
}
else if(opcode(byte(i, file)) == 2){
pause(display, operand(byte(i, file)) * 10);
}
else{
new_pen(s);
}
end(display);
}
}
However when compiling I still get the error message: expected declaration specifiers or ‘...’ before ‘&’ token, but I don't understand why. I've defined the variable s as being part of the structure state and then by using the &s, this gives it the address to follow right?