2012-12-06 136 views
-1

我有一个我的链接列表显示功能的问题。该功能如下。问题与显示功能

我只是在switch语句之一中调用函数。但没有任何显示。请帮我弄清楚我错在哪里。

代码:

void display() 
{ 
    data *cur_point; 

    cur_point = head;  

    if(cur_point = NULL) 
    { 
     printf("The list is empty"); 
    } 
    else 
    { 
     while(cur_point != NULL) 
     { 
      printf("Name : %s \n Contact Number : %d \n",cur_point->name,cur_point->telno); 
      cur_point = cur_point -> nextp; 
     } 
    } 
} 
+0

请编译你的程序时使用最大编译器警告并查看编译器警告并尝试修复它们,它们可以帮助你找出像这样的错误 –

回答

2

更改此:

if(cur_point = NULL) 

要:

if(cur_point == NULL) 

瞧! :)(澄清:你在你的代码中将cur_point设置为NULL,而不是检查它是否为NULL

3

如果你看到这样的事情,应该立即引起恐慌:

if(cur_point = NULL) 

=受让人,==会检查。