链表,操作困难

Linked lists, Manipulation difficulties

我在使用链表操作一些东西时遇到困难,

首先遇到问题的是我的代码的这一部分,我从文件中读取数据,并用它填充我的节点。但是,我在代码中指示的地方不断收到警告,用于分别将指针类型 int 与 int 和不兼容的指针类型进行比较:

void readfile(node *curr, node *newlist, int *quanta, int *readincrement, int *newincrement, int *procnumb)
{
    int i;
    FILE *myFile;
    myFile = fopen("data.txt", "r");
    fscanf(myFile,"%d",quanta);
    fscanf(myFile,"%d",newincrement);
    fscanf(myFile,"%d",readincrement);
    fscanf(myFile,"%d",procnumb);

    newlist = malloc(sizeof(node));
    curr = newlist;
    for(i=0;i<procnumb;i++)//pointer error
    {
        curr->process = 'A' + i;
        printf("%s",curr->process);
        curr->state = '-';
        printf("%s",curr->state);
        fscanf(myFile,"%d",&curr->NUT);
        printf("%d",curr->NUT);
        fscanf(myFile,"%d",&curr->AT);
        printf("%d", curr->AT);
        curr->Prio = '0';
        printf("%d",curr->Prio);
        curr->next = malloc(sizeof (node));
        curr->next = curr;//pointer error.
    }
}

我遇到的第二个问题是将节点从 newlist 的顶部移动到 readylist 的底部的功能,我一直在代码中指出的地方收到错误,我不知道为什么:

//move node from new list, to ready list.
void move(node *newlist, node *readylist)
{
    readylist->next = malloc(sizeof(node));
    while(readylist->next != NULL)
    {
        if(readylist->next == newlist)
            readylist->next = readylist->next->next;//pointer error here.
        readylist = readylist->next;
    }

    readylist->next = newlist;
    newlist->next = NULL;
    return readylist;
}

在你的回答中,我希望能简要解释一下为什么会发生这种情况,我目前正在努力解决这个问题,并且正在努力掌握它。

编辑:忘记在此处添加结构部分:

struct record//too contain several data types.
{
    char process;
    char state;
    int  NUT;
    int  AT;
    int  Prio;

    struct reord *next;
};
typedef struct record node;

void move(node *newlist, node *readylist);

void readfile(node *reading,node *newlist, int *quanta, int *readincrement, int *newincrement, int *procnumb);

main()
{
    int quanta, readincrement, newincrement, procnumb;
    node *readylist = {NULL};//pointing at nothing.
    node *newlist = {NULL};
    node *curr = {NULL};
    node *next = {NULL};
    node *Rcurr = {NULL};
    node *Rnext = {NULL};
}

对于问题 1:

替换

for(i=0;i<procnumb;i++) \这里你比较一个整数和一个指向整数的地址

for(i=0;i<*procnumb;i++)\现在你在比较一个整数和一个整数