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.
ASCII 値 (198) の char '╞' があります。結果のcharが次のいずれかになるように、このcharを操作するにはどうすればよいですか?
0 ~ 9 および A ~ F
後で、結果の文字を元の文字 '╞' に変換したいと思います。
これは10進数から16進数への変換に関する質問だと思います。私はこのようにします
char dec = 198; char hex[3]; sprintf(hex, "%02X", (unsigned char)dec);
元に戻すには、次のようになります
int tmp; sscanf(hex, "%X", &tmp); dec = tmp;
たとえば std::stringstream を使用する方法は他にもありますが、上記は私にとっては問題ありません。