代码显示segmentation fault,有没有大佬能帮忙看一下为什么
#include <stdio.h>struct Entry{
char *name;
char *number;
char *department;
};
void addnumber(struct Entry **library);
void main(void){
struct Entry *directory=NULL;
addnumber(&directory);
}
void addnumber(struct Entry **library){
(**library).name="abcde";
}
#include <stdio.h>
struct Entry{
char *name;
char *number;
char *department;
};
void addnumber(struct Entry **library);
void main(void){
//指针赋值NULL了,不能对它进行操作,应该这么写。
//struct Entry *directory= NULL;
struct Entry dir;
struct Entry *directory= &dir;
addnumber(&directory);
}
void addnumber(struct Entry **library){
(**library).name="abcde";
}
页:
[1]