I have a struct named S and an array of pointers to structs S named A. My function T takes a pointer to struct S as an argument.
struct S *A; //forward declare array A of (pointers to) structs
...
void T(struct S *s){//function that accepts pointer to struct S
...
}
void otherFunction(){
...
T(A[i-1]); //Yields error Incompatible type for argument 1
}
int main(){
A = malloc(100 * sizeof(struct S*)); //initialize array
int i;
for(i = 0; i < NumBowls; i++){
A[i] = malloc(100 * sizeof(struct S));//initialize structs in array
}
otherFunction();
}
With a print statement, I was able to see that A[i-1] is of type struct S, but not pointer to S which is what I wanted. Could this because I forward declared A?