I am unable to pass an array of structures to a function in C.
I created the structure as follows:
int main() { struct Items { char code[10]; char description[30]; int stock; }; struct Items MyItems[10]; }
Then I refer to it like this: MyItems[0].stock = 10; etc.
I want to pass it to such a function:
ReadFile(MyItems);
The function must read the array and be able to edit it. Then I should have access to the same array from other functions.
I tried a bunch of declarations, but none of them work. eg
void ReadFile(struct Items[10])
I was looking for other questions, but the fact is that they are all made different, with typedefs and asterisks. My teacher has not taught us signs yet, so I would like to do this with what I know.
Any ideas ?: S
EDIT: Salvatore's answer works after I corrected my prototype:
void ReadFile(struct Items[10]);
lelouch
source share