Problems with pointers to resolving data stored on linked lists that cannot be exported
The construction of linked lists, and the implementation of linked list access
Use of pointers
Pointers, linked lists, storage of linked lists, access to linked lists
#include <stdio.h>
#include <stdlib.h>//import a C library file to dynamically assign addresses, NULL empty addresses for the bottom malloc
#define MAX 10//11th Max value
typedef struct lnode{//define linked list, linked list structure
int date;
struct Lnode *next;
}lnode;
Storing data in an array on a linked list, storing the list (calling function)
int *create (Lnode *l,int m[],int N) {
Lnode *r,*s; First two linked list pointers
L = (Lnode *) malloc (sizeof (Lnode)); Dynamically assigns a linked list node L, the head pointer.
R = l; Give your head pointer to R and keep your head pointer.
L->next = NULL; Initialization definition of the head pointer
for (int i = 1; i<=n; i++) {//Data link Table storage
s = (lnode*) malloc (sizeof (Lnode));
printf ("Please enter%d numbers in array m: \ n", i);
scanf ("%d", &m[i]);
S->date = M[i]; Using the tail interpolation method to set up the array chain list
R->next = s;
r = r->next;
}
R->next= NULL;
return l; Returns the head pointer of the linked list
}
Data on the output list (call function)
void Prin (Lnode *l) {
L = l->next;
for (int j= 1; j<=10; J + +) {
printf ("%d\n", l->date);
L = l->next;
}
}
Main function
int main (int argc, const char * argv[])
{
Lnode *l;
int M[max];
int n = 10;
Lnode *p =create (L, M, N); Call Linked list build function
Prin (P); Call the linked list output Cheng
Insert code here ...
return 0;
}