home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_11_07
/
1107105a
< prev
next >
Wrap
Text File
|
1993-05-04
|
743b
|
35 lines
// base1.cpp: Shows the bases of integers
#include <iostreams.h>
main()
{
int x, y, z;
cout << "Enter three ints: ";
cin >> x >> y >> z;
cout << x << ',' << y << ',' << z << endl;
// Print in different bases
cout << x << ',';
cout.setf(ios::oct,ios::basefield);
cout << y << ',';
cout.setf(ios::hex,ios::basefield);
cout << z << endl;
// Show the base prefix
cout.setf(ios::showbase);
cout << x << ',';
cout.setf(ios::oct,ios::basefield);
cout << y << ',';
cout.setf(ios::hex,ios::basefield);
cout << z << endl;
return 0;
}
// Sample Execution
// Enter three ints: 10 010 0x10
// 10,8,16
// 10,10,10
// 0xa,010,0x10