Skip to main content
GameDev.net gamedev.net
🔒 Locked

2d std::vector array resizing?

Started by Funkymunky Jan 12, 2008 at 6:55 PM 1 replies 850+ views
Original Post
Funkymunky
Funkymunky
im getting a crash when i try to resize a 2 dimensional vector of ints, declared as such:
std::vector<std::vector<int>> map
i try to resize the "x" dimension like so:
for(int i=0; i<map.size(); i++)
    map.resize(newnum);
yet i get a crash (send error report type crash). why is that?
smart_idiot
smart_idiot
Assuming you intend to write something like map[x][y], you're resizing y, not x. If not, it looks reasonable to me.
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other
Evil Steve
Evil Steve
Quote:
Original post by Funkymunky
yet i get a crash (send error report type crash). why is that?
Because you're not running your code in the debugger, which would tell you more precisely what's wrong; E.g. if it's an access violation, what address was causing it, and point you to the line that was causing it.

You should ALWAYS be running code in the debugger until you think it's completely bug free.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.