+ 1
What's the problem in my code??
I can't find the problem https://code.sololearn.com/cOIgHPiKkSxC/?ref=app
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;
+ 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;