【发布时间】:2016-01-01 16:05:30
【问题描述】:
我正在完成有关机场模拟的课程作业,但在尝试将信息存储在字符数组部分时遇到了一些麻烦。
我应该输入一个字符串,它将存储在节点的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 -> next = temp; //set address of rear to address of temp
rear = temp; //set rear to point to temp
return;
}
This is the error message 在包含以下内容的行中:temp -> planeName = name
这是弹出错误消息的部分,我不知道为什么会发生这种情况。
如果我的问题不够清楚,有人可以帮我问更多问题吗?
【问题讨论】:
标签: c linked-list