Home > Back-end >  Help!!!!!! Read access conflicts
Help!!!!!! Read access conflicts

Time:09-22

Code is
#include
#include
#include
Typedef struct linknode {
Char data;
Struct linknode * next;
} listack;
Void initstack (listack * s) {
S=(listack *) malloc (sizeof (listack));
S - & gt; Next=NULL;
}
Int listackempty (listack * s) {
If (s - & gt; Next==NULL)
return 0;
The else
{
return 1;
}
}
Void listackpush listack * s, char (a) {
Listack * q;
Q=(listack *) malloc (sizeof (listack));
Q - & gt; Data=https://bbs.csdn.net/topics/a;
Q - & gt; Next=s - & gt; next;
S - & gt; Next=q;
}
Bool listackpop (listack * s, char & amp; A) {
Listack * q;
Q=(listack *) malloc (sizeof (listack));
Q=s - & gt; next;
A=q - & gt; The data; //here said the compiler caused abnormal: read access rights conflict, the q is 0 XCCCCCCCC,
S - & gt; Next=q - & gt; next;
Free (q);
return true;
}
Int main () {
Char a;
Listack s;
Initstack (& amp; S);
For (a='a'; A. & lt;=126; {+)
Listackpush (& amp; S, a);
}
While (listackempty)
{
Char b;
Listackpop (& amp; S, b);
Putchar (b);
}
printf("\n");
system("pause");
return 0;
}
To solve the thank you!!!!!

CodePudding user response:

No value given for s next

CodePudding user response:

The
reference 1/f, Simple, Soft reply:
because there is no assignment s next

Can, specific to give directions, thank you

CodePudding user response:

After dinner I help you to look at the source code

CodePudding user response:

reference 3 floor is Simple - Soft reply:
after dinner I help you to look at the source code

Ok, thank you for your bosses

CodePudding user response:

You remove the initstack, initialization is problematic,

#include
#include
#include
Typedef struct linknode {
Char data;
Struct linknode * next;
} listack;

Int listackempty (listack * s) {
If (s - & gt; Next==NULL)
return 0;
The else
{
return 1;
}
}
Void listackpush listack * s, char (a) {
Listack * q;
Q=(listack *) malloc (sizeof (listack));
Q - & gt; Data=https://bbs.csdn.net/topics/a;
Q - & gt; Next=s - & gt; next;
S - & gt; Next=q;
}
Bool listackpop (listack * s, char & amp; A) {
Listack * q;
Q=(listack *) malloc (sizeof (listack));
Q=s - & gt; next;
A=q - & gt; The data;//here said the compiler caused abnormal: read access rights conflict, the q is 0 XCCCCCCCC,
S - & gt; Next=q - & gt; next;
Free (q);
return true;
}
Int main () {
Char a;
Listack * s=(listack *) malloc (sizeof (listack));
S - & gt; Next=NULL;
//initstack (s);
For (a='a'; A. & lt;=126; {+)
Listackpush (s, a);
}
While (listackempty (s))
{
Char b;
Listackpop (s, b);
Putchar (b);
}
printf("\n");
system("pause");
return 0;
}
  • Related