i was trying out setsetiosflags flags but when i tried this example:
1 2 3 4 5 6 7 8 9 10 11 12 13
#include <iostream>
#include <iomanip>
using std::cout;
using std::endl;
using std::setiosflags;
using std::ios;
int main()
{
cout<<setiosflags (ios::hex)<< 100 << endl;
return 0;
}
You forgot to turn off dec flag which have precedence over hex: cout << std::resetiosflags(ios::dec) << setiosflags(ios::hex) << 100 << endl;
If you need to set only one flag, use manipulators: cout << std::hex << 100 << endl;
Or, as cire said, use setf() member function: cout.setf(ios::hex, ios::basefield);