在VC ++中生成带有奇怪字符的二进制字符串

编程入门 行业动态 更新时间:2024-10-24 02:37:57
本文介绍了在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 ++中生成带有奇怪字符的二进制字符串

本文发布于:2023-11-30 11:37:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1649831.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   字符   奇怪   VC

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!