我是C編程語言新手。簡單鏈表分段錯誤
我正在學習關於鏈表的C,試圖打印「hello world」,但我得到了分段錯誤。
我正在使用文本編輯器(vi)和gcc。我如何追蹤錯誤,哪一部分導致分段錯誤,以及如何解決這個問題?
我應該把printf放在everyline中嗎? 我將不勝感激任何幫助/一些建議
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
typedef struct {
int variable;
} abc_create_t;
typedef struct {
int variable;
} pdn_con_t;
typedef struct pdn_con_list_t_slot {
pdn_con_t conn;
struct pdn_con_list_t_slot *next, *prev;
} pdn_con_list_t_slot;
typedef struct {
pdn_con_list_t_slot *head, *tail;
} pdn_con_list_t;
typedef struct {
int variable;
pdn_con_list_t connections;
} gprs_t;
void send_Method(gprs_t *ue, abc_create_t *msg)
{
//assert(ue->connections.head);
printf("IN THIS BLOCK");
}
int main()
{
gprs_t *ue = NULL;
ue->variable=1;
abc_create_t *msg = NULL;
msg->variable=1;
send_Method(ue, msg);
return 0;
}
「你不應該遵循NULL指針,因爲混亂和瘋狂在等着你。」 (第二誡);) – mhyfritz 2011-06-01 10:29:09