+ 1

What's the problem in my code??

I can't find the problem https://code.sololearn.com/cOIgHPiKkSxC/?ref=app

14th Feb 2019, 8:04 AM
êč€ë„현
êč€ë„현 - avatar
2 Answers
+ 3
cout << hex<< (int)&ch<<endl; should be: cout << hex<< (int)ch<<endl; (no &) cout<< hex<< (int)name << endl; does not work at all, because you are converting from an array of characters to an int, so it is not possible. cout<< hex<< (int)&name[0]<<endl; should be: cout<< hex<< (int)name[0]<<endl;
14th Feb 2019, 9:10 AM
Rowsej
Rowsej - avatar
+ 2
êč€ë„현 on line 8 and 10 you can solve the problem by removing the '&'. But you will still have a problem in line 9, because you are trying to cast from 'char*' to int. I would suggest you use a for loop instead: for(int i=0; i<6; i++) { cout << hex << (int)name[i]; } cout << endl;
14th Feb 2019, 9:20 AM
Ulisses Cruz
Ulisses Cruz - avatar