new struct c code example
Example 1: how to initialize a struct in c
typedef struct MY_TYPE {
bool flag;
short int value;
double stuff;
} MY_TYPE;
void function(void) {
MY_TYPE a;
...
a = { true, 15, 0.123 }
}
Example 2: struct in c
typedef struct {
char cognome[30];
char nome[20];
int voto;
}alunno;
Example 3: instance for c in struct
struct listitem {
int val;
char * def;
struct listitem * next;
};
Example 4: instance for c in struct
typedef struct listitem listitem;