小编use*_*328的帖子

在C中的单链表中交换位置

我已经被赋予了为C中的链表创建各种方法的任务.我陷入了交换方法,这似乎搞乱了整个链表.有人对我错在哪里有任何建议吗?干杯!

这是我的代码.

int main(int argc, char* argv[])
{
    // A list of  pointers to Reminders 
    const int MAX_ENTRIES = 10;
    int numOfEntries = 0 ;
    reminder_t* pFirst = (reminder_t*) malloc ( sizeof(reminder_t));
    reminder_t* pSecond = (reminder_t*) malloc ( sizeof(reminder_t));
    reminder_t* pThird = (reminder_t*) malloc ( sizeof(reminder_t));
    reminder_t* pStart = NULL;
    if (pFirst != NULL)
    {
        strcpy( pFirst->message, "Mikes Birthday");
        pFirst->dateOfEvent.day= 1;
        pFirst->dateOfEvent.month= 1;
        pFirst->dateOfEvent.year= 2013;
        pFirst->pNext = NULL;
    }

    if (pSecond != NULL)
    {   
        strcpy( pSecond->message, "Als Soccer Match");
        pSecond->dateOfEvent.day= …
Run Code Online (Sandbox Code Playgroud)

c linked-list singly-linked-list

5
推荐指数
1
解决办法
960
查看次数

标签 统计

c ×1

linked-list ×1

singly-linked-list ×1