Let's say I have this struct
typedef struct
{
int AM;
char* name, surname;
}Item;
and I want to define a constant NULLitem with AM = -1 and NULL name/surname. Is there a way to do it with #define?
CodePudding user response:
#define NULLitem (const Item){ .AM = -1, .name = NULL, .surname = NULL }
That's a C99 compound literal.