std::fixed compile error

Write here if you have problems with your C++ source code

Moderator: Board moderators

Post Reply
Schutzstaffel
New poster
Posts: 37
Joined: Fri Apr 30, 2004 6:52 pm
Location: Portugal

std::fixed compile error

Post 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.
Krzysztof Duleba
Guru
Posts: 584
Joined: Thu Jun 19, 2003 3:48 am
Location: Sanok, Poland
Contact:

Post 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]
Schutzstaffel
New poster
Posts: 37
Joined: Fri Apr 30, 2004 6:52 pm
Location: Portugal

Post by Schutzstaffel »

Thank you, that solved the problem :)
Image
Post Reply

Return to “C++”