這裏是我的代碼:字符串流將unsigned long轉換格式的數字字符串用逗號
unsigned long a_ptr = *(unsigned long*)agent.m_ptr;
std::string a_type = agTypeToText(agent.GetType());
std::string a_cat = agCategoryToText(agent.GetCategory());
std::stringstream selInfo;
selInfo << "Agent pointer: " << a_ptr << "\nAgent type: " << a_type << "\nAgent category: " << a_cat;
,當我顯示此,a_ptr看起來像834993193,當在現實中我希望它顯示爲十六進制數
,像0xFACEF00D,有或沒有0x。有什麼辦法可以用stringstream來做到這一點?
看看[uintptr_t的(http://stackoverflow.com/questions/1845482/ what-is-uintptr-t-data-type) –