Initialize Static Array of Structs in C

Your approach is exactly right.

  1. This will work, and is a good way to avoid huge switch statements.
  2. You can’t define functions inline in C, they each must have a unique name.
  3. extern is what you want, not static. Change your body to be this:

    struct CARD cardDefinitions[] = { 
        {0, 1, do_card0}, 
        {1, 3, do_card1} 
    }; 
    

    then in an appropriate header file:

    extern struct CARD cardDefinitions[];
    

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)