Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cstring string; vs char string;

Tags:

c

char

cstring

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.

like image 508
paeynivek Avatar asked Feb 12 '26 20:02

paeynivek


1 Answers

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.

like image 136
JohnnyHK Avatar answered Feb 15 '26 12:02

JohnnyHK



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!