954,180 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Formatting with Filestream Pointers...

I am having trouble setting the output format while using a pointer to a Filestream:

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 << statLine.period << " ";
        *FSOptr << statLine.epochnumber << " " << statLine.savedextremenumber << endl;
}


The printing works ok, but I can't seem to make the formatting (precision(7)) stick. Any suggestions?

Analogsleeper
Newbie Poster
13 posts since Aug 2005
Reputation Points: 10
Solved Threads: 0
 

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 << <strong>setprecision(7</strong>) << statLine.period << " ";
        *FSOptr << <strong>setprecision(7) </strong> << statLine.epochnumber << " " << statLine.savedextremenumber << endl;
}

dont forget to add up top

nattylife
Newbie Poster
14 posts since Aug 2005
Reputation Points: 10
Solved Threads: 3
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You