Home > Back-end >  Triggered the untreated exception: read access conflict. Q is 0 XCCCCCCCC, for big solutions
Triggered the untreated exception: read access conflict. Q is 0 XCCCCCCCC, for big solutions

Time:05-08

# include
# include
Typedef int Elemtype;
Typedef struct link
{
Int elem.
Struct the link * next;
} the link;
The link * initLink () {
The link * p=(link *) malloc (sizeof (link));//create a head node
The link * temp=p;//declare a pointer to the head node, is used to traverse the list
//generated list
for (int i=1; i <5; I++) {
The link * a=(link *) malloc (sizeof (link));
A - & gt; Elem=I;
A - & gt; Next=NULL;
Temp - & gt; Next=a;
Temp=temp - & gt; Next;
}
return p;
}
Void bianli (link * p)
{
The link * q=p;
While (q - & gt; Next)
{
Q=q - & gt; Next;
Printf (" % d ", q - & gt; Elem);
}
printf("\n");
}
Int main ()
{
The link * p=initLink ();
Bianli (& amp; P);
return 0;
}

Why would address wrong ah, my novice a check not to come out, for bosses to solve

CodePudding user response:

111 to solve!

CodePudding user response:

Reference:
 # include 
# include
Typedef int Elemtype;

Typedef struct link
{
Int elem.
Struct the link * next;
} the link;

The link * initLink ()
{
The link * p=(link *) malloc (sizeof (link));//create a head node
The link * temp=p;//declare a pointer to the head node, is used to traverse the list
//generated list
for (int i=1; i <5; I++) {
The link * a=(link *) malloc (sizeof (link));
A - & gt; Elem=I;
A - & gt; Next=NULL;
Temp - & gt; Next=a;
Temp=a;//temp=temp - & gt; Next;
}
return p;
}
Void bianli (link * p)
{
The link * q=p;
While (q - & gt; Next)
{
Q=q - & gt; Next;
Printf (" % d ", q - & gt; Elem);
}
printf("\n");
}


Int main ()
{
The link * p=initLink ();
Bianli (p);//bianli (& amp; P);

return 0;
}
  • Related