【问题标题】:function prototype with *structure?*结构的函数原型?
【发布时间】:2014-08-12 00:47:26
【问题描述】:

我有一个关于函数原型中指针使用的问题,例如,如果我们有:

Node *AppendList (Node *new_node, Node *head)
{
    Node *walker = head;
    if (head == NULL) 
        return new_node; 
    while (walker->next != NULL)
        walker = walker->next;
    walker->next = new_node;
    return head;
}

我的问题是:为什么 *AppendList 里面有 *?谢谢!

【问题讨论】:

  • 因为你要返回一个指针。

标签: c function pointers linked-list


【解决方案1】:

当您返回一个指针时,您的函数原型应该是 Node *AppendList

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-11-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多