For the past 4 days I've been stuck on this error:
Unhandled exception at 0x77c415de in ls_client_app.exe:
0xC0000005: Access violation reading location 0xcccccccc.
Here 's the code :
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;
this is add_client function:
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;
}
this is the main:
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;
}
Taking me to streambuf file second line !
else if (_Traits::eq_int_type(_Traits::eof(),
overflow(_Traits::to_int_type(*_Ptr))))
break; // single character put failed, quit
else
//...
Could anyone help me please i will be grateful !!
Thanks for trying !!