C++/Console/cout hex


Deprecated: Constant E_STRICT is deprecated in /var/www/cppe.ru/www/includes/exception/MWExceptionHandler.php on line 179

Deprecated: Creation of dynamic property PPDStack::$accum is deprecated in /var/www/cppe.ru/www/includes/parser/Preprocessor_DOM.php on line 803

Deprecated: Constant E_STRICT is deprecated in /var/www/cppe.ru/www/includes/exception/MWExceptionHandler.php on line 179

Deprecated: Constant E_STRICT is deprecated in /var/www/cppe.ru/www/vendor/mediawiki/at-ease/src/Functions.php on line 48
Материал из C\C++ эксперт
Перейти к: навигация, поиск

cout: output hex

#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
  cout << hex << 100 << endl;
  cout << setfill("?") << setw(10) << 2343.0;
  return 0;
}


Set cout: hex and basefield, ios::hex, ios::basefield

#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
  cout.setf(ios::hex, ios::basefield);
  cout << 100 << endl;                  // cout 100 in hex
  cout.fill("?");
  cout.width(10);
  cout << 2343.0;
  return 0;
}