paeynivek
paeynivek

Reputation: 41

cstring string; vs char string;

what is the difference between

typedef struct node *node_ref;
typedef char *cstring;
struct node {
  cstring string;
  node_ref link;
};

and

typedef struct node *node_ref;
struct node {
  char string;
  node_ref link;
};

my program compiles fine with no warnings with either declaration, so I have no idea what difference it made.

Upvotes: 3

Views: 263

Answers (1)

JohnnyHK
JohnnyHK

Reputation: 311865

You've defined cstring as a char * so in the first case string is a pointer to a char and in the second case it's a single char.

Both valid code, but very different meanings.

Upvotes: 4

Related Questions