I am trying to write my array to a file but I have a slight problem. The code below writes the array to the file but it also writes a new line after each element is written and I want the whole array to be written on 1 line. Is there a way to get what I want with ofstream?
Code:
void write_array(void)
{
ofstream outdata;
outdata.open("output.txt");
if( !outdata )
{
cerr << "Error: file could not be opened" << endl;
exit(1);
}
for (int m=0;m<row_3_count;m++)
outdata << code[3][m] << endl;
for (int m=0;m<row_4_count;m++)
outdata << code[4][m] << endl;
for (int m=0;m<string_count;m++)
outdata << code[1][m] << endl;
outdata.close();
}