Mail Archives: djgpp/2001/08/31/23:52:14
Remember, different things are sometimes defined or implimented a littlebit
differently depending on what compiler or OS you are using. That article
you pointed out may have been written with a different comiler in mind. The
following versions should work fine...
///////////////
//
// Program one
//
///////////////
#include <iostream>
int main() {
std::cout.setf(std::ios::dec,
std::ios::basefield);
std::cout.setf(std::ios::right,
std::ios::adjustfield);
std::cout.width(10);
std::cout << 42 << std::endl;
}
///////////////
//
// Program two
//
///////////////
#include <iostream>
#include <iomanip>
int main() {
std::cout.setf(std::ios::hex,
std::ios::right);
std::cout<<std::setw(10)
<<42<<std::endl;
}
Brian Kennedy wrote:
> In message <20010831220708 DOT 29894 DOT qmail AT web10004 DOT mail DOT yahoo DOT com>, chris
> smith (c_smith_1 AT yahoo DOT com) wrote:
>
> :Use ios::right, not std::right.
>
> I didn't think ios::right was the same thing (?).
>
> For example, neither of these two programs (from
> http://www.cuj.com/experts/1902/austern.htm?topic=experts) will compile
> for me. Shouldn't they work with DJGPP?
>
> ///////////////
> //
> // Program one
> //
> ///////////////
> #include <iostream>
> int main() {
> std::cout.setf(std::ios_base::hex,
> std::ios_base::basefield);
> std::cout.setf(std::ios::right,
> std::ios_base::adjustfield);
> std::cout.width(10);
> std::cout << 42 << std::endl;
> }
>
> ///////////////
> //
> // Program two
> //
> ///////////////
> #include <iostream>
> #include <iomanip>
> int main() {
> std::cout << std::hex << std::right << std::setw(10);
> std::cout << 42 << std::endl;
> }
>
> --------------------------------------------------------------
> Brian Kennedy
> brk AT eclipse DOT net
- Raw text -