I have been trying to format output so that it gives two decimal accuracy when it is displayed. The problem I am having is that the "fixed" manipulator for output creates an error.
I was searching around and found the "setiosflags(ios::fixed)" and it works, but I don't know how it works. If I remove the .h from the pre-processor directives and remove the remark symbol before the namespace statement it will allow me to place just "fixed" in the cout statement. If someone could help me understand why I need to use the namespace std or what the setiosflags does, that would be greatly appreciated.Code:#include<iostream.h> #include<iomanip.h> //using namespace std; int main() { cout << "The center of gravity for the loaded plane is " << setiosflags(ios::fixed) << setprecision(2) << CG_filled << " inches from the nose of the aircraft." << endl; return 0; }



LinkBack URL
About LinkBacks


