Address of each character of std::string

穿精又带淫゛_ 提交于 2019-12-03 14:35:22

When a std::ostream tries to print a char* it assumes it's a C-style string.

Cast it to a void* before printing and you will get what you expect:

cout << (void*) &str[i] << endl;

or you may use the old printf

printf("\n%x",&s[i]);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!