Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jan 29th, 2006, 12:19 PM   #1
can342man
Newbie
 
can342man's Avatar
 
Join Date: Jan 2006
Location: London, Ontario, Canada
Posts: 16
Rep Power: 0 can342man is on a distinguished road
Cool column output?

Hi everyone,

Really appreciate all the great help in the past. This might be something very simple but because I am new to C++, I don't know it.

If I wanted to print out a set of numerical data from a 'cout' or 'out' statement so that the data is formatted into 2 columns in such a way that it will be read as 2 separate columns in a spreadsheet.

cout << a << b << endl;

or

out << a << b << endl;

Where 'a' and 'b' would be variables generating a stream of numerical data.

I have tried the '\t' and 'setw (n)' options but it doesn't format it into 2 separate columns of data that can be read by a spreadsheet.

Is there another function or manipulator that I am unaware of that can accomplish this task?

Thanks a lot, really appreciate it.
__________________
Greatness courts failure and solitude.
--- Anonymous
can342man is offline   Reply With Quote
Old Jan 29th, 2006, 4:01 PM   #2
The Dark
Expert Programmer
 
Join Date: Jun 2005
Posts: 852
Rep Power: 4 The Dark is on a distinguished road
Try
cout << a << "," << b << endl;
Then save it to a file with a .csv extension (for Windows anyway)
The Dark is offline   Reply With Quote
Old Jan 30th, 2006, 7:26 AM   #3
can342man
Newbie
 
can342man's Avatar
 
Join Date: Jan 2006
Location: London, Ontario, Canada
Posts: 16
Rep Power: 0 can342man is on a distinguished road
Thanks a lot "The Dark"!!

That worked really well. Renaming the output file to (.csv) made a big difference.

Really appreciate it.
__________________
Greatness courts failure and solitude.
--- Anonymous
can342man is offline   Reply With Quote
Old Jan 30th, 2006, 7:31 AM   #4
nnxion
Programming Guru
 
nnxion's Avatar
 
Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5 nnxion is on a distinguished road
In Excel you can change the character you want to use as delimiter in a comma seperated value(csv) file if you wish.
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for."
-- Socrates
nnxion is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:48 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC