Click to See Complete Forum and Search --> : Tab Deliminated output file


mbanghart
July 30th, 2008, 11:43 AM
Hi,

Does anyone know how to create a tab deliminated output file? My data is in a multidimensional array.

Here is my code, but it doesn't work:


void writeResultMatrix(void)
{
cout << "\nWriting result matrix to file .... ";

ofstream f_out;
f_out.open("myfile.txt", ios::out);

for (int r = 1; r < rows; r++) //for each row
{
//start new line
f_out << "\n";

for (int c = 1; c < columns; c++)
{
f_out << resultArray[c,r];
//tab
f_out << "\t";
}//for
}//outer for

f_out.close();
cout << "DONE\n";
}//void

souldog
July 30th, 2008, 12:22 PM
instead of "\n" and "\t"
use
'\n' and '\t'

mbanghart
July 30th, 2008, 12:53 PM
Thanks! worked.