caphis
04-04-2004, 10:22 PM
Hey guys,
I've just come across something I don't remember from learning Vectors -- how to make a 2-dimensional STL Vector. Basically, height and width will be changing each time the program is run (the array will be filled with char's). My first idea was to do a simple char array via char the2d[width][height], but C++ demands that width and height be constants. I've never really worked with character arrays before, so I then tried a STL Vector.
But the only thing I can't figure out is how to declare a 2-dimensional Vector. Is this even possible with the STL? Or do I need to declare a vector of vector of chars? If so, how do I then access elements, syntaxically?
Or is there a simple workaround -- resizing a character array?
Let me know if I'm making no sense. Thanks guys. :D
I've just come across something I don't remember from learning Vectors -- how to make a 2-dimensional STL Vector. Basically, height and width will be changing each time the program is run (the array will be filled with char's). My first idea was to do a simple char array via char the2d[width][height], but C++ demands that width and height be constants. I've never really worked with character arrays before, so I then tried a STL Vector.
But the only thing I can't figure out is how to declare a 2-dimensional Vector. Is this even possible with the STL? Or do I need to declare a vector of vector of chars? If so, how do I then access elements, syntaxically?
Or is there a simple workaround -- resizing a character array?
Let me know if I'm making no sense. Thanks guys. :D