0

I am studying C++ after learning C language. When I check inside value of array, I am used to printing hex value of array. But, I couldn't print hex value of char array with COUT.

void Mystr::print(){
    for (int i=0;i<string_length+1;i++){
        cout << hex << string[i];       // 'hex' effects only memcap & string_length value
        printf ("[%x]",string[i]);      // it can print hex value of each character
    }
    cout << endl;
    cout <<"Memcap : " << memcap <<endl;
    cout <<"string length : " << string_length <<endl;
}

'cout << hex' can't make an effect on character value. how can I look up hex value of character array with COUT ?

Changil Lee
  • 157
  • 1
  • 1
  • 6

0 Answers0