C语言错误
程序代码:
#include <stdio.h> typedef struct student { char name[12]; int id; }student; typedef struct node { student data; struct node *next; }*node; node *create_link() { node *head; head = (node *)malloc(sizeof(node)); if(head == NULL) { printf("申请空间失败"); exit(0); } printf("................\n"); // error: request for member 'data' in something not a structure or union head->next = NULL; // error: request for member 'data' in something not a structure or union head ->data->name[0] = '\0'; return head; } void add_link(node *head) { } void print_link(node *head) { node *temp = head; while(temp != NULL) { printf("%s ", temp->data.name);// error: request for member 'data' in something not a structure or union printf("%s ", temp->data.name);// error: request for member 'data' in something not a structure or union printf("%d ", temp->data.id);// error: request for member 'data' in something not a structure or union temp = temp ->next; } putchar(10); } int main(void) { node *head=create_link(); print_link(head); printf("Hello World!\n"); return 0; }