In article <11**********************@i39g2000cwa.googlegroups .com>,
"saltedcoffee" <as***********@hotmail.com> wrote:
hey, I am beginer to C++ programing.
I am working on a project called the "maze Problem"
First of all I am required to read a text file in( which is the maze)
and store it into a 2 dimentional vector.
This is what I have till now:
#include <iostream>
#include "maze.h"
#include <vector>
#include <fstream>
using namespace std;
int main()
{
typedef vector< vector<char> > vectorMaze;
//get the name of the file
ifstream mazeFile;
cout<< "Enter name of file name with the maze: "<<endl;
while(!mazeFile.eof())
{
getline(cin,vectorMaze);
}
I feel there are errors with the above attempt too, but I also don't
know how to put this input into a 2-d vector.
Any help would be appreciated.
Thanks......
You need a Matrix class, and you need to start small and work your way
up.
#include <iostream>
// put any extra includes you need here
class Matrix {
// put your code here
};
int main() {
Maxrix matrix( 1, 1 ); // create a 1 by 1 cell matrix of char
matrix.at( 0, 0 ) = 'x';
assert( matrix.at( 0, 0 ) == 'x' );
cout << "Working!\n";
}
Add code to the "put your code here" spot until you can get. The above
to compile, and when run print "Working!" on the screen. Once you get
that done, post what you have and we'll give you the next step.
--
Magic depends on tradition and belief. It does not welcome observation,
nor does it profit by experiment. On the other hand, science is based
on experience; it is open to correction by observation and experiment.