我通常在python中编程.为了提高我的模拟性能,我正在学习C.在向链表实现追加函数时,我有一个问题需要理解指针指针的使用.这是我的书(由Kanetkar理解C指针)中的代码的摘录.
#include <stdlib.h>
#include <stdio.h>
struct node{
int data;
struct node *link;
};
int main(){
struct node *p; //pointer to node structure
p = NULL; //linked list is empty
append( &p,1);
return 0;
}
append( struct node **q, int num){
struct node *temp, *r; //two pointers to struct node
temp = *q;
if(*q == NULL){
temp = malloc(sizeof(struct node));
temp -> data = num;
temp -> link = NULL;
*q = temp;
}
else{
temp = *q;
while( temp -> …Run Code Online (Sandbox Code Playgroud)