如何将字节数组转换为字符串? [英] How to convert a byte array to a string?

查看:81
本文介绍了如何将字节数组转换为字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我使用多播并通过网络接收压缩数据包。我在指定的内存块'''''解压缩数据包(声明为lzo_byte * in)... 。现在,我想将''in'转换为字符串并在控制台上显示结果(并将其保存在磁盘上)...我该怎么做?


任何帮助都会非常实用....

提前致谢....干杯

Hello all,
I used multicasting and received compressed data packets over the network.I decompressed the packets at a specified memory block ''in''(declared as lzo_byte *in)....Now,i want to convert ''in'' to a string and display the result on the console(and also save it on disk)...How do i do this?

Any help will be really useful....
Thanks in advance....Cheers

推荐答案


Hello all,

我使用多播并通过网络接收压缩数据包。我在指定的内存块''''中解压缩数据包(声明为lzo_byte * in) ....现在,我想将''in''转换为字符串并在控制台上显示结果(并将其保存在磁盘上)...我该怎么做?


任何帮助都非常实用....

提前致谢....干杯
Hello all,
I used multicasting and received compressed data packets over the network.I decompressed the packets at a specified memory block ''in''(declared as lzo_byte *in)....Now,i want to convert ''in'' to a string and display the result on the console(and also save it on disk)...How do i do this?

Any help will be really useful....
Thanks in advance....Cheers



是字节有意义的字符或整数数字数据中的信息?

最简单的方法是让一个for()循环通过数组以你需要的格式打印每个元素。

is the information in the bytes meaningful characters or integer numeric data?
The simplest thing is to have a for() loop go thru the array printing each element in the format you require.


感谢您的快速回复....

内存块in有积分值和字符....我已经在捕获数据包时使用了''for()''循环.....所以''in''的每个元素都已经占了...我现在如何在文件中写出来?


干杯
Thanks for the quick response....
The memory block "in" has integar values as well as characters....I have already used a ''for()'' loop while capturing the data packets.....so every element of ''in'' is already accounted for...how do I write it in a file now?

Cheers



感谢您的快速响应....

内存块in有积分值和字符....我已经在捕获数据包时使用了''for()''循环.....所以''in''的每个元素都已经占了...我现在如何在文件中写它?


干杯
Thanks for the quick response....
The memory block "in" has integar values as well as characters....I have already used a ''for()'' loop while capturing the data packets.....so every element of ''in'' is already accounted for...how do I write it in a file now?

Cheers



你可以在C中使用fopen()打开一个文件

http://www.cplusplus.com/fopen


或C ++中的ostream

http://www.cplusplus .com / reference / iostream /


你可以写出二进制信息,例如您的字节数组,或字符和/或数字文本表示

http://tools.devshed.com/c/a/Web-Development/C-File-IO-and-Binary-File -IO /

http://www.cplusplus.com/doc/tutorial/files.html

you can open a file using fopen() in C
http://www.cplusplus.com/fopen

or ostream in C++
http://www.cplusplus.com/reference/iostream/

you can either write out binary information, e.g. your byte array, or the character and/or numeric text representation
http://tools.devshed.com/c/a/Web-Development/C-File-IO-and-Binary-File-IO/
http://www.cplusplus.com/doc/tutorial/files.html


这篇关于如何将字节数组转换为字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆