Passing an array of structs in C

struct Items
{
    char code[10];
    char description[30];
    int stock;
};

void ReadFile(struct Items items[10])
{
    ...
}

void xxx()
{
    struct Items MyItems[10];
    ReadFile(MyItems);
}

This in my compiler works well.
What compiler are you using? What error you got?

Remember to declare your struct before your functions or it will never work.

Leave a Comment