Home > Back-end >  VS read access conflict 0 XCCCCCC variable initialization problem
VS read access conflict 0 XCCCCCC variable initialization problem

Time:09-19

, as shown in the p=p - & gt; Next step will pop up read access conflict, but consider the initialization problem in the team function have p - & gt; Next=NULL, how to analysis?


Attached to the source:
# define _CRT_SECURE_NO_WARNINGS 1
# define Max 4
#include
#include
#include
#include
#include
#include
/* * client node type definition/
Typedef struct qnode
{
Char data (Max);
Struct qnode * next;
} LinkNode;
The definition of *//* chain team
Typedef struct {LinkNode * front; LinkNode * rear; } LinkQueue;
/* queue initialization */
Void initial (LinkQueue * & amp; Q)
{
Q=(LinkQueue *) malloc (sizeof (LinkQueue));
Q - & gt; The front=q - & gt; Rear=NULL;
}
Void inqueue (LinkQueue * & amp;//q, int e, char a) registered team note: parameter (chain, queue number)
{
Char s [4]={0};
LinkNode * p=(LinkNode *) malloc (sizeof (LinkNode));
P - & gt; Next=NULL;
If (q - & gt; Rear==NULL) q - & gt; The front=q - & gt; Rear=p;//if the current chain team is null, the current and head for the team and of the newly inserted node
The else
{
Q - & gt; Rear - & gt; Next=p; There will be a new node to the next morning//
Q - & gt; Rear=p;//will be members of the pointer to the
}
If (e & gt; 0 & amp; & E & lt; 10)
{

S [0]=a;
S [1]='0';
S [2]='0';
S [3]=10 + 48 e %;
Strcpy (p - & gt; The data, s);
Printf (" \ n -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- \ n \ n ");
Printf (" take no success! Your number is: % s ", p - & gt; The data);
}
Else if (e & gt;=10 & amp; & E & lt; 100)
{
P - & gt; Data [0]=a;
P - & gt; Data [1]='0';
P - & gt; Data [2]=e/10;
P - & gt; Data [3]=e/10% 10;
Strcpy (p - & gt; The data, s);
Printf (" \ n \ n -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- \ n \ n ");
Printf (" take no success! Your number is: % s ", p - & gt; The data);
}
Else if (e & gt;=100 & amp; & E & lt; 1000)
{
P - & gt; Data [0]=a;
P - & gt; Data [1]=e/100;
P - & gt; Data [2]=e/10% 10;
P - & gt; Data [3]=e % 10;
Strcpy (p - & gt; The data, s);
Printf (" \ n \ n -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- \ n \ n ");
Printf (" take no success! Your number is: % c % d ", a, e);
}
}
Void outqueue (LinkQueue * & amp; Q)//ChuHao out team
{
LinkNode * p;
If (q - & gt; Rear==NULL)
{
Printf (" currently there is no need for service!" );
}
P=q - & gt; The front;//temporary node point to team head
If (q - & gt; The front==q - & gt; Q - rear) & gt; The front=q - & gt; Rear=NULL;//the original queue only one node, the team head and empty of the node
The else q - & gt; The front=q - & gt; The front - & gt; Next;//more than one node, the head node of the directly to the team (team a head pointer (one-way)
free(p);
}
Void cancel (LinkQueue * & amp; Q, int e)
{
Printf (" do you want to cancel the line? If cancel, carries on the service you need to the end of the line! \n");
Printf (" press Y to continue, press any other key to continue waiting... \n\n");
If (_getch ()=='Y' | | _getch ()=='Y')
{
Printf (" are you sure you want to cancel this line? Press Y for final confirmation, press any other key to continue waiting... \n");
If (_getch ()=='Y' | | _getch ()=='Y')
{
for (int i=0; i
}
}
}
Void destroy (LinkQueue * & amp; Q)
{
system("cls");
LinkNode * pre=q - & gt; The front;//create a new node point to team head node
LinkNode * p;
char c;
Printf (" the work... Input Y key confirmed destroyed the queue, others return to main menu... ");
getchar();
The scanf (" % c ", & amp; C);
If (c=='Y' | | c=='Y')
{
If (pre!=NULL)//when the team head node is not empty (not completed the team destroyed)
{
P=pre - & gt; Next;//pointer to pre's subsequent node
While (p!=NULL)//when the subsequent node is not NULL
{
Free (pre);//release team head node
The pre=p;//team head node back
P=p - & gt; Next; Subsequent//team head node back
}
free(q);//end of the cycle still remains team head node, release, destruction of end
}
}
The else system (" CLS ");
}
Void num_count (LinkQueue * & amp; Q)
{
int i=0;
LinkNode * p=q - & gt; The front;
While (p!=NULL)
{
i++;
P=p - & gt; Next;
}
Printf (" \ n -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- \ n \ n ");
Printf (" % d current queue have waiting for the service to the customer! Press any key to return to main menu... ", I);
_getch (); system("cls");
}
Void inqueue_menu (LinkQueue * q, int I)
{
Restart:
Printf (" -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- \ n \ n ");
Printf (" -- -- -- -- -- - the savings bank service registration system -- -- -- -- -- - \ n \ n ");
Printf (" -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- \ n \ n ");
Printf (" -- -- -- -- -- - please enter service code you want to take a number -- -- -- -- -- - \ n \ n ");
Printf (" -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- \ n \ n ");
Printf (" -- -- -- -- -- - 1. The deposit management -- -- -- -- -- - \ n \ n ");
Printf (" -- -- -- -- -- - 2. Loan management -- -- -- -- -- - \ n \ n ");
Printf (" -- -- -- -- -- - 3. Transfer the remittance -- -- -- -- -- - \ n \ n ");
Printf (" -- -- -- -- -- - 4. Consulting -- -- -- -- -- - \ n \ n ");
Printf (" -- -- -- -- -- - 5. The settlement of exchange of foreign -- -- -- -- -- - \ n \ n ");
Printf (" -- -- -- -- -- - 6. Global service -- -- -- -- -- - \ n \ n ");
Printf (" -- -- -- -- -- - 7. The livelihood of the people to expend -- -- -- -- -- - \ n \ n ");
Printf (" -- -- -- -- -- - 8. Personal Settings -- -- -- -- -- - \ n \ n ");
Printf (" -- -- -- -- -- - 0. Return -- -- -- -- -- - \ n \ n ");
Printf (" -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- \ n \ n ");
Printf (" service number: ");
int a; The scanf (" % d ", & amp; A);
The switch (a)
{
Case 1: inqueue (q, I, 'C'); break;
Case 2: inqueue (q, I, 'D'); break;
Case 3: inqueue (q, I, 'Z'); break;
Case 4: inqueue (q, I, 'L'); break;
Case 5: inqueue (q, I, 'J'); break;
Case 6: inqueue (q, I, 'q'); break;
Case 7: inqueue (q, I, 'M'); break; nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related