void 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].password,password);
sta[j].compInsur=0;
sta[j].staffInsurance=0;
sta[j].staffSalary=0;
sta[j].staffTax=0;
sta[j].takeSalary=0;
}
運行到sta[j].compInsur=0;就出現這個報錯
uj5u.com熱心網友回復:
第一呼叫這個函式沒有報錯,第二次呼叫的時候就報錯了
uj5u.com熱心網友回復:
是地址非法訪問了,檢查一下前面字串的賦值操作uj5u.com熱心網友回復:
void 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].password,password);
sta[j].compInsur=0;
sta[j].staffInsurance=0;
sta[j].staffSalary=0;
sta[j].staffTax=0;
sta[j].takeSalary=0;
++j;
}
}
uj5u.com熱心網友回復:
建議提供更多的資訊(代碼),根據錯誤判斷很可能是記憶體溢位了(陣列越界)轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/61547.html
標籤:C語言
