Maze Project

This is a discussion on Maze Project within the C++ Programming forums, part of the General Programming Boards category; Ok i have anouther question. This one stumps me. Does the fstream fuctions "file.open(file.txt)" not work with #define? I keep ...

Ok i have anouther question. This one stumps me. Does the fstream fuctions "file.open(file.txt)" not work with #define? I keep getting 98 errors and then i took away the #define stuff and only errors i got where ones i would expect from values not being identified. Whats going on?

A #define will work simular in function to a variable that you cannot change. Your compiler will change all occurances in your code from 'SizeOfMazeX' to '10' before it compiles your code. Its just an easy way to keep track of things. Without the define, if we were to change the size of the maze we would have to change all the for...loops as well as the definition of the maze array. This makes life easier (and safer).

You shouldnt be getting any errors... Unless your trying to change the value of SizeOfMazeX or SizeOfMazeY? Possibly by reading to them from a file?

Right away I notice something. #defines are not terminated with a semi-colan.

This:

#define maxX 20; //<--- Semi-Colan = bad

should be this:

#define maxX 20

That should solve it... Works now?

P.S. I'm having the occasional problem connecting to cprogramming.com right now.... not sure why. Replies may become delayed or cease completly. This submission has failed 3 times already... waiting.... still waiting... we'll see what happens...

I dont have time to explain all that stuff, I'm sorry. Its 12:30 here and I'm one of those poor SOBs that have to get up at 6:30 and go to work. You might want to look up info on file I/O. Check out fopen, fread, and fwrite for (In my opinion) a superior method of file I/O... unless as I suspect, you're required to use iostream... Then look for an iostream tutorial (i'll try to find you one).