#include <iostream> using namespace std; void wyswietlLancuch(const string &str) { cout << str << dec << "( " << str.length() << " )" << endl; for(string::const_iterator it = str.begin(), epos = str.end(); it != epos; ++it) { cout << hex << (static_cast<int>(*it) & 0xff); cout << ", "; } } int main() { string tekst = "ĄĆŻŹąćżź"; cout << "Tekst z kodu: "; wyswietlLancuch(tekst); cout << endl; cin >> tekst; if (!tekst.empty()) { cout << "Tekst wprowadzony: "; wyswietlLancuch(tekst); cout << endl; } }
ĄĆŻŹąćżźa
Tekst z kodu: ĄĆŻŹąćżź( 16 ) c4, 84, c4, 86, c5, bb, c5, b9, c4, 85, c4, 87, c5, bc, c5, ba, Tekst wprowadzony: ĄĆŻŹąćżźa( 17 ) c4, 84, c4, 86, c5, bb, c5, b9, c4, 85, c4, 87, c5, bc, c5, ba, 61,