我有一個現有的std :: string和一個int。我想將int附加到字符串中,但是以可讀的形式(十六進制表示法)而不是二進制亂碼。如何將數據追加到十六進制格式的std :: string?
通常情況下,我只是用printf,但我不能用的std :: string(可以嗎?)
任何建議,如何做到這一點做到這一點?
Example:
Given:
std::string - "Your Id Number is: "
int - 0xdeadc0de
Output:
std::string - "Your Id Number is: 0xdeadc0de"
的std :: showbase應另外使用到std ::十六進制以「0x」前綴整型的代表權OP的要求完全匹配 – 2009-08-10 15:00:42