Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
std::stringusingで数値/16 進値を置き換えよstd::replaceうとしていますが、試してみると、位置の 1 文字をvaluefileBuf.replace(0x10, 1, "0x44");に置き換えるのではなく、文字列を ASCII "0x44" に展開するだけです。これを行う適切な方法はありますか?ありがとう0x100x44
std::string
std::replace
fileBuf.replace(0x10, 1, "0x44");
0x10
0x44
\x16 進文字を表すには、エスケープ シーケンスを使用する必要があります。さらに、1 文字だけを置換するため、文字列リテラルではなく文字リテラルを使用できます。
\x
fileBuf.replace(0x10, 1, '\x44');