void function(stuct *s) 和 void function(stuct s) 有什么区别?
Whats the difference between void function(stuct *s) vs void function(stuct s)?
我有这个学校作业要做,我被要求做的功能弄糊涂了。和我做单链表的风格不一样
我是这样做单链表的:
typedef struct structNode{
int data;
struct structNode *next;
} node;
typedef struct structList{
int count;
struct structNode *head, *tail;
} list;
void insertFront(list *L, int x);
void insertRear(list *L, int x);
void insertAt(list *L, int x, int p);
void deleteFront(list *L);
void deleteRear(list *L);
void deleteAt(list *L, int p);
void displayAll(list *L);
所有参数都收到一个指针,但我的作业需要我这样编写代码:
typedef struct node *nodePtr;
struct node {
int item;
nodePtr next;
};
typedef nodePtr Statistician;
Statistician newStatistician();
//allocates memory to the structure. Dynamic allocation
void destroyStatistician(Statistician *s);
//destroys statistician
void add(Statistician s, int x);
//Adds data to the rear
void remove(Statistician s, int x);
//removes data
void displayData(Statistician s);
所以我很困惑有什么不同,因为我习惯于接受指点,而且作业风格不同。
我认为带有接收指针的那个是通过引用调用的,这就是为什么我在本地编辑的内容可以在全局编辑...
我的结构实现与我必须执行的结构实现有何不同?
统计学家是指针。它被定义为 nodePtr,而 nodePtr 又被定义为 node*。所以传递一个Statistician实际上就是传递一个node*.
从可用性的角度来看,使指针看起来像非指针是否明智是另一个问题。
我有这个学校作业要做,我被要求做的功能弄糊涂了。和我做单链表的风格不一样
我是这样做单链表的:
typedef struct structNode{
int data;
struct structNode *next;
} node;
typedef struct structList{
int count;
struct structNode *head, *tail;
} list;
void insertFront(list *L, int x);
void insertRear(list *L, int x);
void insertAt(list *L, int x, int p);
void deleteFront(list *L);
void deleteRear(list *L);
void deleteAt(list *L, int p);
void displayAll(list *L);
所有参数都收到一个指针,但我的作业需要我这样编写代码:
typedef struct node *nodePtr;
struct node {
int item;
nodePtr next;
};
typedef nodePtr Statistician;
Statistician newStatistician();
//allocates memory to the structure. Dynamic allocation
void destroyStatistician(Statistician *s);
//destroys statistician
void add(Statistician s, int x);
//Adds data to the rear
void remove(Statistician s, int x);
//removes data
void displayData(Statistician s);
所以我很困惑有什么不同,因为我习惯于接受指点,而且作业风格不同。
我认为带有接收指针的那个是通过引用调用的,这就是为什么我在本地编辑的内容可以在全局编辑...
我的结构实现与我必须执行的结构实现有何不同?
统计学家是指针。它被定义为 nodePtr,而 nodePtr 又被定义为 node*。所以传递一个Statistician实际上就是传递一个node*.
从可用性的角度来看,使指针看起来像非指针是否明智是另一个问题。