vtrap2009
2008-10-10 08:17:10 UTC
class Maze {
public:
Maze();
bool loadMaze(int level); //loads maze0.txt for level 0 or
// maze1.txt for level 1, etc. Returns true iff file was found
//(you may assume it is valid).
void display() const; //prints the maze to the screen
//for this to be more useful in GacMan you are required to print
//the maze ONE character at a time regardless of how you store it
private:
//whatever you need here, mazes will 23 wide by 21 high
};
And, this is what I've got so far in a separate .cpp file:
#include "Maze.h"
#include
#include
#include
#include
using namespace std;
Maze::Maze(){}
//loads maze0.txt for level 0 or
// maze1.txt for level 1, etc. Returns true iff file was found
//(you may assume it is valid).
bool Maze::loadMaze(int level) {
int max=23;
char fileName[24];
sprintf_s(fileName,23,"maze%d.txt",level);
//create ifstream and open file:
ifstream input(fileName);
if (input.is_open())
{
while(!input.eof())
{
input.getline(fileName,max,'\n');
}
return true;
}
return false;
input.close(); //close file
}
void Maze::display()const {}
void main(){
Maze test;
cout<<"Outputs a 1 if maze was successfully loaded: "<
I'm having problems loading the text files. It doesn't appear to even open it??