extern istream& ws(istream& ins); // whitesp. aus istream entf. extern ostream& flush(ostream& outs); // Puffer eines ostream leeren extern ostream& endl(ostream& outs); // '\n' an ostream anhaengen extern ostream& ends(ostream& outs); // '\0' an ostream anhaengen inline ios& dec(ios& i) { i.setf(ios::dec, ios::dec|ios::hex|ios::oct); return i; } inline ios& hex(ios& i) { i.setf(ios::hex, ios::dec|ios::hex|ios::oct); return i; } inline ios& oct(ios& i) { i.setf(ios::oct, ios::dec|ios::hex|ios::oct); return i; }
// File: StreaB01.cc #include <iostream.h> int main() { int i, j; cout << "Zwei Zahlen, getrennt durch Whitespaces, eingeben:" << endl; cin >> ws >> i >> ws >> j; cout << dec << '|' << i << '|' << j << '|' << endl; cout << oct << '|' << i << '|' << j << '|' << endl; cout << hex << '|' << i << '|' << j << '|' << endl; }Programmausgabe:
Zwei Zahlen, getrennt durch Whitespaces, eingeben: |16|32| |20|40| |10|20|