After looking at the same few lines for an hour now, I cannot figure out why the user named input file isn't opening and the user named output file isn't even being created. I used the debugger in visual studio 05 to figure out the input file isn't being opened successfully. I am working on 2d arrays and playing with the individual elements and moving them around. I am still working on the screen output and I don't have to many comments to walk through the code easily.
example input file for code reading purposes:
2
3
abc
def
ghi
2
st
uv
Code:
#include <iostream>
#include <fstream>
using namespace std;
void reversemajor(char matrix[][5], char major[][5], int matrixsize);
void reverseminor(char matrix[][5], char minor[][5], int matrixsize);
int main()
{
ifstream input;
ofstream output;
int numberofarrays, matrixsize, i, j, k;
char infilename[30], outfilename[30];
char matrix[5][5], arrays[5][5];
char major[5][5], minor[5][5];
cout << "Please enter the input file name." << endl;
cin >> infilename;
cout << "Please enter the output file name." << endl;
cin >> outfilename;
input.open(infilename);
output.open(outfilename);
input >> numberofarrays;
for (i = 0; i < numberofarrays; i++)
{
input >> matrixsize;
for (k = 0; k < matrixsize; k++)
for (j = 0; j < matrixsize; j++)
input >> matrix[k][j];
//reading each array element
for (k = 0; k < matrixsize; k++)
{
for (j = 0; j < matrixsize; j++)
{
arrays[k][j] = matrix[k][j];
//making a copy of array
}
reversemajor(matrix, major, matrixsize);
reverseminor(matrix, minor, matrixsize);
for (k = 0; k < matrixsize; k++)
for (j = 0; j < matrixsize; j++)
output << arrays[k][j];
//outputting to file
for (k = 0; k < matrixsize; k++)
for (j = 0; j < matrixsize; j++)
output << major[k][j];
for (k = 0; k < matrixsize; k++)
for (j = 0; j < matrixsize; j++)
output << minor[k][j];
}
}
input.close();
output.close();
return 0;
}