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;

}

Recommended Answers

All 2 Replies

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.

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

been awhile since i had done 2 dimesional arrays.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.