I am implementing a queue in C. I have a struct like:
struct Node {
Node* next;
Node* previous;
// data
}
Because next and previous are just pointers, does it make a difference if I use Node* or int*? eg:
struct Node {
int* next;
int* previous;
// data
}
Using
int *is incorrect and results in undefined behavior. You can use eitherNode *orvoid *, but if you use any type other thanNode *, it’s going to require a cast (or implicit conversion, e.g. via an assignment) back toNode *before you can dereference it.