Formatting with Filestream Pointers...

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Aug 2005
Posts: 13
Reputation: Analogsleeper is an unknown quantity at this point 
Solved Threads: 0
Analogsleeper Analogsleeper is offline Offline
Newbie Poster

Formatting with Filestream Pointers...

 
0
  #1
Aug 23rd, 2005
I am having trouble setting the output format while using a pointer to a Filestream:

  1. struct statLine{
  2. int id;
  3. int primary_type;
  4. int secondary_type;
  5. double period;
  6. double epochnumber;
  7. int savedextremenumber;
  8. }statLine;
  9.  
  10. void printStatLine(ofstream *FSOptr)
  11. {
  12. FSOptr->precision(7);
  13. *FSOptr << statLine.id << " " << statLine.primary_type << " " <<statLine.secondary_type << " ";
  14. *FSOptr << statLine.period << " ";
  15. *FSOptr << statLine.epochnumber << " " << statLine.savedextremenumber << endl;
  16. }

The printing works ok, but I can't seem to make the formatting (precision(7)) stick. Any suggestions?
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 14
Reputation: nattylife is an unknown quantity at this point 
Solved Threads: 3
nattylife nattylife is offline Offline
Newbie Poster

Re: Formatting with Filestream Pointers...

 
0
  #2
Aug 24th, 2005
do you mean setprecision()?
yer gonna need to insert it into the stream before your data likeso

struct statLine{
int id;
int primary_type;
int secondary_type;
double period;
double epochnumber;
int savedextremenumber;
}statLine;

void printStatLine(ofstream *FSOptr)
{
        //FSOptr->precision(7);
        *FSOptr << statLine.id << " " << statLine.primary_type << " " <<statLine.secondary_type << " ";
        *FSOptr << setprecision(7) << statLine.period << " ";
        *FSOptr << setprecision(7)  << statLine.epochnumber << " " << statLine.savedextremenumber << endl;
}
dont forget to add <iomanip> up top
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C Forum
Thread Tools Search this Thread



Tag cloud for C
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC