0

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?

2
Contributors
1
Reply
2
Views
12 Years
Discussion Span
Last Post by nattylife
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 << [B]setprecision(7[/B]) << statLine.period << " ";
        *FSOptr << [B]setprecision(7) [/B] << statLine.epochnumber << " " << statLine.savedextremenumber << endl;
}

dont forget to add <iomanip> up top

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.