传递指针有关问题

传递指针问题
大家帮忙看下下面的代码,我想在链表中依次从头插入10个元素,为什么for循环的结果head的值是0,而其next指针域
却是NULL?????
C/C++ code

typedef struct Node
{
    int data;
    struct Node* next;
}Node;
//头插法创建链表
bool CreateList(Node* head, int value)
{
    Node* pNode;
    if(-1 == head->data)
    {
        head->data = 0;
        head->next = NULL;
    }
    else
    {
        pNode = new Node;
        pNode->data = value;
        pNode->next = head;
        head = pNode;
    }
    return true;
}
int main()
{
    int array[] = {0,1,2,3,4,5,6,7,8,9};
    Node head;
    head.data = -1;
    for(int i = 0; i < 10; i++)
        CreateList(&head, array[i]);   //我传递的就是head的地址呀!
}


------解决方案--------------------
head 是一个变量,它的地址是一个常量是不会改变的,你只可以改变head.data的值。
第一次执行了 if(-1 == head->data)
{
head->data = 0;
head->next = NULL;
}
所以它的data值变为0。
以后每次执行都没有修改head.data,所以一直都是0;
你可以定义一个指针,这样你就可以改变它指向的地址,可以这样试一下
typedef struct Node
{
int data;
struct Node* next;
}Node;
//头插法创建链表
Node *CreateList(Node* phead, int value)
{
Node* pNode;
if(-1 == phead->data)
{
phead->data = 0;
phead->next = NULL;
}
else
{
pNode = new Node;
pNode->data = value;
pNode->next = phead;
phead = pNode;
}
return phead;
}
int main()
{
int array[] = {0,1,2,3,4,5,6,7,8,9};
Node head;
Node *phead=NULL;
phead = &head;
phead->data = -1;
for(int i = 0; i < 10; i++)
{
phead = CreateList(phead, array[i]); //我传递的就是head的地址呀!
}
}
------解决方案--------------------
探讨

Node *CreateList(Node* phead, int value)
那么我为什么不能在形参中传递指针修改phead呢,而不用返回值?