How to display the text from a text file in rows?

Hi guys,

Facing another issue. I have a text file with some data.
When I add records to this text file, it will save as such:

table:200:21022011
chair:100:21022011
laptop:200:21022011
etc, etc

The thing is when I tried to display it, the display will actually how it was written.
This is the code that I have typed

int Transaction::viewexpense(string toView)
{
string line;
ifstream myfile ("transaction.txt");
if (myfile.is_open())
{
while (myfile.good())
{
getline (myfile,line,':');
cout << line << endl;
}
myfile.close();
}
else cout << "File does not exist!";
return 0;
}


How can I write this code so that it can display like easy to read records
eg:

Item Cost Date
-----------------------------------
table 200 21022011
chair 100 21022011
laptop 200 21022011


Thanks in advance!!
Topic archived. No new replies allowed.