| | |
Formatting with Filestream Pointers...
![]() |
•
•
Join Date: Aug 2005
Posts: 13
Reputation:
Solved Threads: 0
I am having trouble setting the output format while using a pointer to a Filestream:
The printing works ok, but I can't seem to make the formatting (precision(7)) stick. Any suggestions?
C Syntax (Toggle Plain Text)
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?
•
•
Join Date: Aug 2005
Posts: 14
Reputation:
Solved Threads: 3
do you mean setprecision()?
yer gonna need to insert it into the stream before your data likeso
dont forget to add <iomanip> up top
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;
}![]() |
Similar Threads
- void pointers (C++)
- formatting problems (Windows NT / 2000 / XP)
- Reading a few chars from FileStream (C)
Other Threads in the C Forum
- Previous Thread: printf & cout
- Next Thread: abt algoritham complexity
| Thread Tools | Search this Thread |
#include * ansi array arrays asterisks bash binarysearch calculate centimeter changingto char character convert copyanyfile copyimagefile creafecopyofanytypeoffileinc createprocess() database dynamic execv fgets file floatingpointvalidation fork framework function getlogicaldrivestrin givemetehcodez grade gtkwinlinux histogram ide inches include infiniteloop initialization input interest intmain() iso keyboard km license linked linkedlist linux list looping lowest matrix meter microsoft number oddnumber open opendocumentformat openwebfoundation owf pdf pointer pointers posix power probleminc process program programming pyramidusingturboccodes radix read recursion recv recvblocked research reversing scheduling segmentationfault send sequential single socket socketprogramming standard strchr string suggestions systemcall test testautomation testing threads turboc unix urboc user variable whythiscodecausesegmentationfault win32api windowsapi





