In gdb, I’m getting a “Cannot access memory at address [ ]” The program, at the moment, runs fine but I’m perplexed why I cannot access it right.
http://hastebin.com/wulomoqimu – main.cpp
http://hastebin.com/hahosuruhe – player.h
These are, I believe the relevent files.
*(playerNames+i) = (players+i) -> name;
*(playerCards+i) = (players+i) -> hand;
*(playerScores+i) = (players+i) -> score;
And some lines I’m not sure about. Thanks for any help.
playerNamesis pointing to an array of string pointers. Which means you have allocated memory to pointers that can point to string objects. The array is filled with some garbage addresses as of now.Here you are dereferencing with out array pointing to no valid string object addresses. You have to make each array index pointing to a valid memory address before dereferencing.
Now the array is filled with valid string object addresses.