I was trying to format my output by using fixed<<showpoint. The compiler doesn't recognize this. I have included <iomanip>. Is there something else I shoud include.
Thanks Kristin
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I may be wrong, but I don't think the plain 'fixed' and 'showpoint' are standard ANSI C++. I've seen it around, but I suspect that it may be a Microsoft corruption of the language... Can anyone here confirm this, or else post a reference to the ANSI C++ standard about it (if it is indeed part of the standard)?
qWake
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I may be wrong, but I don't think the plain 'fixed' and 'showpoint' are standard ANSI C++. I've seen it around, but I suspect that it may be a Microsoft corruption of the language... Can anyone here confirm this, or else post a reference to the ANSI C++ standard about it (if it is indeed part of the standard)?
qWake
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have mostly seen it in the form you showed it, though, to tell the truth, when I have had to control my prints, I have tended to use printf. Its weird, but I feel more comfortable with that.
Wayne (the weird)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This is to show use. play the the number in setprecision.
the cout.setf(ios::fixed,ios::showpoint); sets the flag for every time you use cout from cout.setf(ios::fixed,ios::showpoint); down.
You're not so weird Wayne, I also find printf easier to use for formatted output. The printf formatting tokens may be more obscure to new programmers than the clearer "setprecision(2)" found in C++, but they are much more compact.
qWake
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I was trying to format my output by using fixed<<showpoint. The compiler doesn't recognize this. I have included <iomanip>. Is there something else I shoud include.
Thanks Kristin
Use this instead:
cout << setiosflags(ios::fixed | ios::showpoint);
I may be wrong, but I don't think the plain 'fixed' and 'showpoint' are standard ANSI C++. I've seen it around, but I suspect that it may be a Microsoft corruption of the language... Can anyone here confirm this, or else post a reference to the ANSI C++ standard about it (if it is indeed part of the standard)?
qWake
Use this instead:
cout << setiosflags(ios::fixed | ios::showpoint);
I may be wrong, but I don't think the plain 'fixed' and 'showpoint' are standard ANSI C++. I've seen it around, but I suspect that it may be a Microsoft corruption of the language... Can anyone here confirm this, or else post a reference to the ANSI C++ standard about it (if it is indeed part of the standard)?
qWake
qWake,
I have mostly seen it in the form you showed it, though, to tell the truth, when I have had to control my prints, I have tended to use printf. Its weird, but I feel more comfortable with that.
Wayne (the weird)
Try setf.cout (ios::fixed | ios::showpoint);
oops this is right ... cout.setf (ios::fixed | ios::showpoint);
This is to show use. play the the number in setprecision.
the cout.setf(ios::fixed,ios::showpoint); sets the flag for every time you use cout from cout.setf(ios::fixed,ios::showpoint); down.
#include <iostream>
#include <stdlib.h>
#include <iomanip>
using namespace std;
int main()
{
cout.setf(ios::fixed | ios::showpoint);
double xnan = 13.72;
int numb;
double num;
numb = rand()%14307;
num = (numb / xnan);
cout << setprecision(6)<< num << endl;
system("PAUSE");
return 0;
}
You're not so weird Wayne, I also find printf easier to use for formatted output. The printf formatting tokens may be more obscure to new programmers than the clearer "setprecision(2)" found in C++, but they are much more compact.
qWake