Modernes C++ programmieren

Okt 23, 2024

lst-0872-book.cpp

// https://godbolt.org/z/4MY1Yznv9 
#include <iostream>
using std::cout; using std::endl;
int main() {
    int val = 255;
    std::ios::fmtflags ff = std::cout.flags();
    cout.flags(std::ios::hex | std::ios::showbase);
    cout << val << endl;  // Ausgabe: 0xff
    cout.flags(ff);
    cout << val << endl;  // Ausgabe: 255
}