Dynamicly sized arrays
Dec 18, 2012 at 2:47pm UTC
Hey, I'm messing around with making a cards against humanity clone for educational purposes but I'm running into a a little problem
I'm making the hardest bit first (the white cards) but I've hit a snag.
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 int main ()
cardlist.open ( "wcards.txt");
int cardnumber = 0;
string cardarray [cardnumber];
cardarray[cardnumber] = cardtext;
cout << cardarray;
it compiles and then it breaks
Process terminated with status -1073741510 (0 minutes, 9 seconds)
I think it's the way I've tried to keep expanding the array but I'm not sure. Any insight you could give would be useful, thanks.
Dec 18, 2012 at 2:56pm UTC
The size of the array is decided by the value of cardnumber on line 7. cardnumber is 0 so the size of the array will be zero and it's not possible to later change the size. You should consider using a container like std::vector that can change size.
Dec 18, 2012 at 3:06pm UTC
Last edited on
Dec 18, 2012 at 4:54pm UTC
Topic archived. No new replies allowed.