I\'m having trouble passing an array of structs to a function in C.
I\'ve created the struct like this in main:
int main()
{
struct Items
{
You need to use pointer to array, after that its easy to access its members
void ReadFile(Items * items);
should work.
Well, when you pass a structure like you did, it actually creates a local copy of it in the function. So it will have no effect on your original structure, no matter how you modify it in ReadFile
.
I am not sure about a different approach and this might not answer your question, but I recommend you try pointers. You'll definitely be using them quite a lot in C/C++. And they can be really powerful once you master them
Have you tried to declare you function like this:
void ReadFile(struct Items[])
Might be helpful: http://www.daniweb.com/software-development/cpp/threads/105699