I need to make a 2-dimensional character vector so I can input data from a txt file into it however I cannot seem to find any clear way of doing this online. Also how would you make it to the right size (would you use .resize()). Cheers
Are you sure you want a 2D vector and not a vector of structures\classes that hold two variables?
AFAIK you can't make a 2D vector with the Standard lib. Think about it; it would be a continous block of memory that holds a variable number of elements who are them selves continous blocks of memory that are a variable size. Maybe some extended library has a way to fake this but I don't know of one.
Could you outline your issue in a little more detail?
I have been set to solve a maze which is in a text file which I will put below. So I was wanting to read the txt file using the istream and put the characters which make up the maze in to a 2-dimensional vector. I would use an array however my program should be able to solve any maze in a text file in the same format.
x = wall
p = path
g = goal
Always N x N maze and N is at the top of the text file i.e. 10 in this case
Nope, a string can be treated as an array of chars with a variable length, this is because a string is an array of chars with a variable length. Each string entry would be a row and each element in the vector would be a new line. At this point it seems like a pretty good solution.