我经历了一本书正在学链表,看到这些线路什么(节点*)NULL在C意味着什么?
if(*head == NULL){
}else if ((*head)->next == (node *) NULL){
}
是什么NULL
和(node *) NULL
之间的差异,他们可以互换使用?
typedef struct nodeType{
int info;
struct nodeType *next;
}node;
我经历了一本书正在学链表,看到这些线路什么(节点*)NULL在C意味着什么?
if(*head == NULL){
}else if ((*head)->next == (node *) NULL){
}
是什么NULL
和(node *) NULL
之间的差异,他们可以互换使用?
typedef struct nodeType{
int info;
struct nodeType *next;
}node;
它们可以互换使用。但是,与您的代码一样,这是非标准并且不常见的类型为NULL
。
不需要强制转换。
这意味着代码的作者不知道他在做什么。 'NULL'不需要强制转换。 – asveikau 2012-03-22 03:24:10
这只是混淆。指针不需要在条件中与NULL进行比较。 'if(* head)'和'if((* head) - > next)'会完美。 – 2012-03-22 07:28:32