Multiple dimensions

+1 Earl Hudson · February 4, 2015

I haven't seen any tutorials that covers anything close to what I want to do.( Hey Bucky -- You get that? lol)  

It sounds easy enough. It turns out to be a challenge for me. I have a data file of integers, 52 lines long, 10 ints per line. i want to read the file, and insert it the data either into a multidimensional array, or a multidimensional vector. I think I have read somewhere that arrays cause memory leaks but I'm not certain. Does anyone have some advice to offer as to which direction I should go? Maybe a sniplet of code or even some pseudo code  to get me started in the that direction? Thank you very much in advance.

Post a Reply


Oldest  Newest  Rating
0 Earl Hudson · February 8, 2015
Of course it's silly to someone that knows the proper methods. I don't think I'm doing to bad for the length of time I have vested in C++, self taught with Buckys videos. :)   Shrug... could be wrong.. oh well, I thank you for your advise in any event sir,
0 Jay Deshaun · February 4, 2015
Multidimensional Array -
Multidimensional Vector -

I think this would be good enough.

Not sure about Memory Leaks though
0 Earl Hudson · February 7, 2015
Okay, I'm still having problems. Let me try this another way... Just for giggles and funnzies I'm trying to write an old school text adventure. I mean OLD school... back in the late 70's when the home computer craze started, and you could hold your head high if you had a TI-994A, or a vic-20 ... most people had a commodore 64, and you had 64K to work with. The only languages were basic and assembler.  Text adventures were done with arrays (single and multi-dimensional)... everything else was smoke and mirrors with some global variables, gosubs and well crafted if / then statements. Okay, I hope I explained that well enough. :)

I need a routine to basically do this:

open file "room.dat", scan through and count the lines. close file. Set number of lines to x.
declare room [x] [10]
reopen the file, and assign the int's to the array.
close the file.

There is getline, cin.getline, >> extractor, and what not. I have tried to put the getline inside a loop, that was fun. I've tried the ten variable route and use cin to bring in the variables one at a time... I was ashamed of that one. (Don't tell no one) Now seriously..  What is the best method to achieve this? What do I need to read up on to get this task accomplished? Is there some Pseudo  code, flowchart or a tutorial or something out there I can't find that covers this? Which direction do I need to go here?  As always, thank you in advance.
0 Earl Hudson · February 4, 2015
Hi Jay,

 Thank you for your prompt response. I know how vectors, arrays and multidimensional arrays are initialized and accessed from within the code... Reading the dat file into the md-array has been a problem,  and trying to read the dat file into a md-vector has been a nightmare for me.
  • 1



Used in many types of software including music players, video games, and many large scale applications.

Bucky Roberts Administrator