在过去的 4 天里,我一直遇到这个错误:
Unhandled exception at 0x77c415de in ls_client_app.exe:
0xC0000005: Access violation reading location 0xcccccccc.
这是代码:
typedef struct client {
string ID;
// some other strings
} client;
typedef struct client_card {
client CLIENT;
client_card * next;
} client_card;
typedef client_card * ls_client;
这是 add_client 函数:
int add_client(ls_client &LS_CLIENT) {
client NEW_CLIENT;
ls_client NEW_CLIENT_CARD = (ls_client) malloc (sizeof(client_card));
cout << "CLIENT ID: " <<endl;
cin >> NEW_CLIENT.ID;
NEW_CLIENT_CARD->next = NULL;
NEW_CLIENT_CARD->CLIENT = &NEW_CLIENT;
while (LS_CLIENT != NULL) {
LS_CLIENT = LS_CLIENT->next;
}
LS_CLIENT = NEW_CLIENT_CARD;
return 0;
}
这是主要的:
int main() {
ls_client LS_CLIENT = (ls_client) malloc (sizeof(client_card));
LS_CLIENT = NULL;
add_client(LS_CLIENT);
// Error in this line !
cout << LS_CLIENT->CLIENT->ID <<endl;
return 0;
}
带我去streambuf文件第二行!
else if (_Traits::eq_int_type(_Traits::eof(),
overflow(_Traits::to_int_type(*_Ptr))))
break; // single character put failed, quit
else
//...
谁能帮助我,我将不胜感激!
感谢您的尝试!