0

why does the output file look completely different than the input file... what am i doing wrong here?

#include <iostream>
#include <cstdlib>
#include <fstream>
using namespace std;

int main () {
    
    char maze[10, 10];
    int x, y;
    ifstream file; 
    ofstream output;
    
    file.open ("maze.txt");
    
    for (y = 0; y < 10; y++){
        
        for (x = 0; x < 10; x++){
        
            file >> maze[x,y];
            cout << maze[x,y];
            
        }
        
        cout << endl;
    
    }
    
    file.close ();
    cout << endl;
    output.open ("pathtaken.txt");
    
    for (y = 0; y < 10; y++){
        
        for (x = 0; x < 10; x++){
        
            output << maze[x,y];
            cout << maze[x,y];
        
        }
     
        cout << endl;
    
    }

    output.close ();
    
    cin >> x;
    return 0;

}
Attachments
OOOOOOOOOO
OXOOXXXXXX
OXOOOOOXOO
OXXXXXOXXO
OXOOOOOXOO
XXOOOXXXOO
OXOXXXOOOO
OXOXOXOOOO
OXXXXXXXOO
OOOOOOOOOO
2
Contributors
2
Replies
3
Views
12 Years
Discussion Span
Last Post by jhdobbins
0

well for starters look up the comma operator and see how its not helping you out here. Secondly look up proper multidimensional array use. I posted some code in the airplane seats thread that uses a 2d array. check it out for a sample.

0

thanks alot... i forgot about doing the [][] instead of [ , ].

been awhile since i had done 2 dimesional arrays.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.