I'm trying to write to a text file, and keep getting this error message:
gedit has not been able to detect the character encoding.
Please check that you are not trying to open a binary file.
Select a character encoding from the menu and try again.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
void write_maze(char *filename, char *maze, int rows, int cols)
{
ofstream solved (filename);
if (! solved.is_open()){
cout << "Failed to open " << filename << endl;
}
solved << rows << " " << cols;
for (int i = 0; i <= (rows * cols); i++) {
solved << maze[i];
if (! ((i + 1) % cols)) {
solved << endl;
}
}
solved.close();
}
What am I doing wrong? It was working earlier with a very basic file, but that didn't suit my purposes.