singly linked chain printing c++

后端 未结 6 589
刺人心
刺人心 2021-01-28 18:39

I am trying to pick my chain in the format {1,2,3,4,etc}. You can find the header file below which will have the layout of the nodes. I am just confused on how I should go about

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-28 18:59

    Without testing, I'd do something like this. (Assumes the last node has Succ set to NULL, as I would recommend it does.)

    void LoopList(struct Node *head)
    {
        for (struct Node *p = head; p != null; p = p->Succ)
        {
            // Do whatever with this node
            Print(p);
        }
    }
    

提交回复
热议问题