Home > Back-end >  0 xc0000005 access conflict, ask god for help
0 xc0000005 access conflict, ask god for help

Time:09-22

Void the add (STAFF sta [], char * name, char * username, char * password)
{
int i=0,j=0;
While (sta [j] staffID [0]!='\ 0') + + j;
Strcpy (sta [j] staffID, name);
Strcpy (sta [j]. Name, username);
Strcpy (sta [j]. The password, the password).
The sta [j] compInsur=0;
The sta [j] staffInsurance=0;
The sta [j] staffSalary=0;
The sta [j] staffTax=0;
The sta [j] takeSalary=0;
}



Run to the sta [j]. Journal of compInsur=0; This error appears

CodePudding user response:

The
refer to the original poster weixin_45985307 response:
void the add (STAFF sta [], char * name, char * username, char * password)
{
int i=0,j=0;
While (sta [j] staffID [0]!='\ 0') + + j;
Strcpy (sta [j] staffID, name);
Strcpy (sta [j]. Name, username);
Strcpy (sta [j]. The password, the password).
The sta [j] compInsur=0;
The sta [j] staffInsurance=0;
The sta [j] staffSalary=0;
The sta [j] staffTax=0;
The sta [j] takeSalary=0;
}



Run to the sta [j]. Journal of compInsur=0; Appear this error

No error, the first call this function when a second call error

CodePudding user response:

Is the address illegal access, check the string in front of the assignment operation

CodePudding user response:

 void the add (STAFF sta [], char * name, char * username, char * password) 
{
int i=0,j=0;
While (sta [j] staffID [0]!='\ 0')
{
Strcpy (sta [j] staffID, name);
Strcpy (sta [j]. Name, username);
Strcpy (sta [j]. The password, the password).
The sta [j] compInsur=0;
The sta [j] staffInsurance=0;
The sta [j] staffSalary=0;
The sta [j] staffTax=0;
The sta [j] takeSalary=0;
+ + j;
}
}

CodePudding user response:

Suggest to provide more information (code), according to the error judgment is likely to be a memory leak (an array)
  • Related