我目前正在学习C,但是我面对的是链表,这种情况我真的不明白。
我创建了以下程序:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct list
{
int age;
char name[256];
struct list *next;
};
void displayList ( struct list *node );
int main( void )
{
struct list *node = malloc ( sizeof ( struct list ) );
node->age = 10;
strcpy( node->name, "Kiara" );
node->next = malloc ( sizeof ( struct list ) );
node->next->next = NULL;
displayList( node );
free( node->next );
free( node );
}
void displayList ( struct list *node ) …Run Code Online (Sandbox Code Playgroud)