小编Kat*_*Lee的帖子

我无法在链表的节点中存储字符串

我正在做关于机场模拟的课程,我在尝试将信息存储在角色阵列部分时遇到了一些麻烦.

我应该输入一个字符串,它将存储在planeName节点的一部分,但它似乎无法工作.我int main()现在几乎是空的,因为我不想继续使用不正确的函数进行编码.

以下是我的代码:

struct node {
    char planeName[5];
    int planeNumber;
    struct node* next;
}; 

struct node* front = NULL;
struct node* rear = NULL;

void Enqueue(char name[5], int x);

int main() {

}

void Enqueue(char name[5], int x){

    struct node* temp = (struct node*)malloc(sizeof(struct node));

    temp -> planeName = name; 
    temp -> planeNumber = x;
    temp -> next = NULL;

    if (front == NULL && rear == NULL)
        front = rear = temp;
    rear -> …
Run Code Online (Sandbox Code Playgroud)

c linked-list

4
推荐指数
1
解决办法
876
查看次数

标签 统计

c ×1

linked-list ×1