-
unsetting setprecision
I am currently trying to write a simple program that will perform various operations on two numbers inputted. I want the result to be formatted with a decimal point and a precision of 2. The program is an infinite loop until you actually quit. The problem I'm encountering is as follows:
The first iteration of the program works fine. The numbers I input are displayed exactly as inputted and the result is formatted the way I want using << fixed << showpoint << setprecision(2). Subesequent iterations display the numbers inputted in the same format as the result, i.e. with decimal point and a precision of 2.
Once I use fixed showpoint setprecision, how do I turn them off before the next iteration is performed?
-
3 errors on line 112
`fixed' undeclared (first use this function)
(Each undeclared identifier is reported only once
for each function it appears in.)
`showpoint' undeclared (first use this function)
-
Make sure you tell the compiler what functions you will use form the namespace standard.
Code:
using std::fixed;
using std::showpoint;
cin.setf(fixed | showpoint);
cin.unsetf(fixed | showpoint);
setiosflags(fixed | showpoint);
resetiosflags(fixed | showpoint);
long flag = cin.precision();
cin.flags(flag);
Kuphryn