# include & lt; stdio.h>
#include
#include
Struct node
{
int num;
Struct node * next;
} the node;
Void main ()
{
Struct node num, * head, * p=head;
//int ordinal=1, remain=13;
//set up 13 node
//logging data in the node num:
1 ~ 13
If (p!=NULL) printf (" Not NULL... \n");
Printf (" % d ", p - & gt; Num);
for(int i=0; i<13; I++)
{
P - & gt; Num=I + 1;
Printf (" % d ", p - & gt; Num);
P=p - & gt; next;
}
P=NULL;
Bother everybody to help, thank!
CodePudding user response:
The head is wild pointerCodePudding user response:
The suspension is to point to? Reference code modifications of the building Lord, generate the lead 13 nodes of the node list, at the same time to deposit 1-13, for reference:# include & lt; stdio.h>
#include
#include
Struct node
{
int num;
Struct node * next;
} the node;
Void main ()
{
Struct node num, * head, * p, * q;
//int ordinal=1, remain=13;
//set up 13 node
//logging data in the node num:
1 ~ 13The head=(struct node *) malloc (sizeof (struct node));
The head - & gt; Next=NULL;
Q=head;
If (q!=NULL) printf (" Not NULL... \n");
//printf (" % d ", p - & gt; Num);
for(int i=0; i<13; I++)
{
P=(struct node *) malloc (sizeof (struct node));
P - & gt; Num=I + 1;
P - & gt; Next=NULL;
Q - & gt; Next=p;
Q=p;
Printf (" I=% d, % d \ n ", I, p - & gt; Num);
//p=p - & gt; next;
}
Q=head - & gt; next;
While (q) {
Printf (" % d \ n ", q - & gt; Num);
Q=q - & gt; next;
}
//p=NULL;
system("pause");
}