I am using visual studio 2012 writing normal c++ and I keep getting this error for a variable I have declared.
1>c:\users\joe\skydrive\documents\c++\consoleapplication2\matracies 1.cpp(182): error C2065: 'file' : undeclared identifier
1>c:\users\joe\skydrive\documents\c++\consoleapplication2\matracies 1.cpp(184): error C2065: 'file' : undeclared identifier
This is the function where I am getting the error.
void WriteMatrix(vector<vector<float>> Matrix, float row, float col, int choice)
{
if (choice == 1)
{
ofstream file("MultiplyMatrix.txt", ios::app);
}
else if (choice == 2)
{
ofstream file("AddMatrix.txt", ios::app);
}
else if (choice == 3)
{
ofstream file("AddMatrix.txt", ios::app);
}
for(int i=0; i<row; i++)
{
for(int j=0; j<col; j++)
{
float temp = Matrix[i][j];
file<<temp<<" ";
}
file<<endl;
}
file<<endl;
file.close();
}