Akos Nagy Akos Nagy - 4 years ago 116
C Question

What is the type of b in this code snippet?

typedef struct node {
int value;
struct node *next;
} NodeT;
const NodeT *a,b,c;


Is variable b actually a constant struct element?

Answer Source

Is variable b actually a constant struct element?

Your b has type const NoteT, which means const struct node, as the declaration :

const NoteT *a,b,c;

is equivalent to :

const NoteT *a;
const NoteT b;
const NoteT c;

In general, if you have a declaration like :

type *x, y, z, *w, ... ;

the type type applies to all variable, but only those who have a * in front of them are pointers to that type.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download