本文介绍了在VC ++中生成带有奇怪字符的二进制字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
不使用二进制编写器需要根据VC ++中的某些十六进制数据30303054313032202020303030生成带有奇怪字符的二进制字符串 输入十六进制:5430323120302030302030 输出:6? ? ? ? ? ?
Without using binary writer need to generate a binary string with weird character based on some hex data "30303054313032202020303030" in VC++ Input Hex:5430323120302030302030 Output :6
推荐答案在我看来,这样的字符串不代表奇怪的字符(它代表以下字符序列000T102 000 )。 您必须:
- 将字符串转换为 unsigned char 的数组s(字符串的每个有序字符串代表 unsigned char )
- 将unsigned char数组写入二进制文件(例如,使用 fwrite function(或 ofstream :: write 方法)。 Such a string does not represent ''weird characters'', in my opinion (it represents the following character sequence "000T102 000"). You have to:
- convert the string into an array of unsigned chars (each ordered pair of characters of your string represent an unsigned char)
- write the unsigned char array to a binary file (using, for instance fwrite function (or ofstream::write method).
更多推荐
在VC ++中生成带有奇怪字符的二进制字符串
发布评论