Page 1 of 1

std::fixed compile error

Posted: Fri Apr 30, 2004 6:59 pm
by Schutzstaffel
Hey, I'm trying to submit a problem but the online judge doesn't recognise the std::fixed, I use it in the following line:

Code: Select all

std::cout << std::fixed << std::setprecision(4)<< distances[i] << " ";
I also have include of the iostream and iomanip (besides others needed for the problem).

The online judges says:
02493452_24.c: In function `int main()':
02493452_24.c:47: `::fixed' undeclared (first use here)
Does anyone have any ideia of what might it be?
Thanks for your attention.

Posted: Fri Apr 30, 2004 7:25 pm
by Krzysztof Duleba
Use the following code instead:
[cpp]std::cout.setf(std::ios::fixed);
std::cout.precision(4);
[/cpp]
You will probably also want to use
[cpp]std::cout.setf(std::ios::showpoint);[/cpp]

Posted: Fri Apr 30, 2004 7:33 pm
by Schutzstaffel
Thank you, that solved the problem :)