Skip to content

Instantly share code, notes, and snippets.

@zinosama
Last active September 12, 2018 23:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zinosama/bd3b9d3111a50b3a75ec352a6dcde6a6 to your computer and use it in GitHub Desktop.
Save zinosama/bd3b9d3111a50b3a75ec352a6dcde6a6 to your computer and use it in GitHub Desktop.
C question about array of structs
typedef struct transition* Transition;
typedef struct state* State;

struct state {
  int goal;
  int transition_cnt;
  Transition transitions; // points to a transition[]
};

struct transition {
  char el;
  State next_state;
};

struct transition t;
struct state s;
s.goal = 0;
s.transition_cnt = 1;
// I'd like to assign a one-element array {t} to the transitions pointer of s
s.transitions = &{t}; // this raises an error 'expected expression' in xcode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment