|
From: Jason H. <jas...@bt...> - 2001-10-26 03:09:42
|
The commented code should be inside the main function, between the two {}.
Also you need to qualify the scope of the flags in the first, so:
cout << ios::fixed << ios::showpoint;
Which will compile in Dev-C++, although I have noticed it outputs a weird
number, but I'll let you sort that out.
The second commented code works fine (assuming you put it inside main()).
The last won't work, but it's not needed as you should use ios:: and not
ios_base::
I've attached some code for you to work with.
Jason.
----- Original Message -----
From: "Marton Rusk" <mar...@ho...>
To: <dev...@li...>
Sent: Friday, October 26, 2001 3:46 AM
Subject: [Dev-C++] newbie needs help
> Hello all,
>
> I'm a programming student currently in my C++ part 2 class.
>
> Please tell me why the following code gives me errors with any of the
three
> commented floating point formatting code un-commented? I get errors with
> three different compilers.
>
> If anyone knows how to fix this please help. Or, if anyone knows another
way
> to format floating point data please help.
>
> Thanks,
>
> Marton D. Rusk
>
>
> #include <iostream>
> #include <iomanip>
>
> using namespace std;
>
> //cout << fixed << showpoint; //don't work
>
> //cout.setf(ios::fixed, ios::floatfield); //don't work
> //cout.setf(ios::showpoint);
>
> //cout.setf(ios_base::fixed, ios_base::floatfield); //don't work
> //cout.setf(ios_base::showpoint);
>
> int main(){
>
> float number = 3.57890;
>
> cout << number;
> return 0;
> }
>
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
>
>
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|