Actually I think you are maybe wrong... because 13x4=52...
This is a discussion on Weird command prompt error, program not working.. within the C++ Programming forums, part of the General Programming Boards category; Actually I think you are maybe wrong... because 13x4=52......
Actually I think you are maybe wrong... because 13x4=52...
Sometimes I forget what I am doing when I enter a room, actually, quite often.
Code:class Deck { public: Deck() { int x; int y; int z = 0; for (y = 0; y < 4; y++) { for (x = 0; x < 13; x++) { Cards[z].suit = y; Cards[z].value = x; z++; } } } //private: Card Cards[52]; };
I used to be an adventurer like you... then I took an arrow to the knee.
But 4 * 14 is 56!
And your second loop will run 0..13, which is 14 iterations, not 13, just like your first loop runs 0..3, which is 4 iterations.
[Just because I made one mistake doesn't mean that everything else I said is wrong!]
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
awesome its all fixed up now, thanks for your help guys
Code:struct Card { int suit; int value; }; class Deck { public: Deck() { int x; int y; int z = 0; for (y = 0; y < 4; y++) { for (x = 0; x < 13; x++) { Cards[z].suit = y; Cards[z].value = x; z++; } } } //private: Card Cards[52]; };
Sometimes I forget what I am doing when I enter a room, actually, quite often.