ios an undeclared identifier?

I'm working on my first C++ assignment, and am trying to use "cout.setf(ios::showpoint). But when I did, I got a compiler error saying that ios is an undeclared identifier (see screenshot at http://awesomescreenshot.com/080jnfv20).

I'm developing using XCode 4 on Mac OS 10.7.1. Since I'm a new C++ programmer, this is probably something basic that I just don't know, perhaps about C++, perhaps about XCode.

Thanks for any advice you can offer.
is it that you want to show fractional part? I do it like: cout<<fixed<<showpoint; and it works. Have a look here: http://recurseit.blogspot.com/2011/08/fahrenheit-to-celsius.html
Hope it helps
My goal was to change the formatting of a number to give it a decimal point and two digits after the decimal point - e.g., "20.00" instead of just "20". I'm not sure that the stuff I was trying to use is the right way to do that - I was just starting to experiment with it when I ran into this "ios undeclared" problem.

Thanks for the link to your page. I'll play around with trying the stuff you show there. The "setprecision" call looks particularly useful, and I wasn't aware of it before.
Yeah the functions like setprecision are quite useful. If you want to search more you can search 'output formatting functions'. I will also be uploading similar problems on my blog. And you can ask me there directly too. I would be glad to help :)
closed account (zb0S216C)
Possible Solutions:
1) Implicitly cast the floating-point value to a integer (possible loss of data as a result).
2) Prefix ios with std::.

The first possible solution cuts out stream manipulators. However, if stream manipulators are required, try the second solution.

Wazzak
Thanks for your help. I'm embarrassed to say though that, when I went in and tried the same thing today, there was no error generated when I used ios, in what I think was the same manner I tried to use it yesterday. I have no explanation, other than I guess that something was messed up in my environment, or that something was inadvertently temporarily messed up in my code.

I'm glad to report that, based on the tips I've received here, I have learned today to use setprecision to do exactly what I needed to do. I think the assignment is working perfectly, and I've turned it in.

Thanks again for your help, cplusplusers! You've created a really super friendly and helpful environment here!
Last edited on
Topic archived. No new replies allowed.