| | |
Formatting with Filestream Pointers...
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
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 |
Tag cloud for C
adobe ansi api append array arrays bash binarysearch centimeter char character cm convert copyanyfile copypdffile createcopyoffile createprocess() csyntax directory dynamic execv feet fflush fgets file floatingpointvalidation fork frequency function getlasterror getlogicaldrivestrin givemetehcodez global graphics gtkgcurlcompiling hardware highest homework i/o ide infiniteloop initialization interest intmain() kilometer license linked linkedlist linux linuxsegmentationfault list match matrix meter microsoft mqqueue multi mysql oddnumber odf open openwebfoundation pattern pause pdf pointer pointers posix power program programming pyramidusingturboccodes read recursion recv recvblocked repetition scheduling segmentationfault send shape single socketprogramming stack standard strchr string strings structures suggestions system test testautomation unix urboc user voidmain() whythiscodecausesegmentationfault win32api windows.h





