Hum, beetje wazig. Mijn C++ boek vindt dit goed. MS VC wil het weer anders:
C++:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
| Example
// ios_showbase.cpp
// compile with: /EHsc
#include <iostream>
int main( )
{
using namespace std;
int j = 100;
cout << showbase << j << endl; // dec is default
cout << hex << j << showbase << endl;
cout << oct << j << showbase << endl;
cout << dec << j << noshowbase << endl;
cout << hex << j << noshowbase << endl;
cout << oct << j << noshowbase << endl;
}
Output
100
0x64
0144
100
64
144 |
In mijn boek staat hetzelfde type voorbeeld als:
C++:
1
2
3
4
5
6
7
8
9
| #include <iostream.h>
#include <iomanip.h>
int main()
{
int x = 100;
cout << setiosflags(ios::showbase) << "Waarde: " << x << '\n' << oct << x << '\n'<< hex << x << endl;
return 0;
} |
Weer een ander boek wil het als:
C++:
1
2
| cout.setf( ios::showbase | ios::hex );
cout << "Waarde: " << x << endl; |
Niet echt uniform allemaal geloof ik
[
Voor 29% gewijzigd door
SWfreak op 17-07-2003 09:44
]