HELP请 - 如何将字符串转换为字节数组 [英] HELP PLEASE - How to convert string to byte array

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

问题描述

有些C大师可以帮帮我吗?字节是C中的无符号字符。

如何从C字符串转换为相应的字节数组。任何

帮助将不胜感激。

Could some C guru help me please? A byte is an unsigned char in C.
How do I convert from a C string to a corresponding byte array. Any
help would be greatly appreciated.

推荐答案

cp ********** @ yahoo.com 潦草地写道:
一些C大师可以帮助我好吗?字节是C中的无符号字符。
如何从C字符串转换为相应的字节数组。任何
帮助将不胜感激。
Could some C guru help me please? A byte is an unsigned char in C.
How do I convert from a C string to a corresponding byte array. Any
help would be greatly appreciated.




你不需要转换它。 AC字符串可以像字节一样使用
数组。


例如:

char * s =" Hello,world !" ;;

char c = s [0]; / * c现在包含''H''* /


-

/ - Joona Palaste(pa*****@cc.helsinki .fi)-------------芬兰-------- \

\ ------------- -------------------------------------------规则! -------- /

糟糕的事情只发生在恶棍身上。

- Moominmamma



You don''t need to "convert" it. A C string can be used like a byte
array.

For example:
char *s = "Hello, world!";
char c = s[0]; /* c now contains ''H'' */

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-------------------------------------------------------- rules! --------/
"Bad things only happen to scoundrels."
- Moominmamma


cp**********@yahoo.com 写道:
有些C大师可以帮帮我吗?一个字节是C中的无符号字符。


否,''byte''是''char''的同义词,可以是签名的,也可以是

未签名。无符号字节是无符号字符。是否有任何

类型对应于,例如,八位字节取决于

实现。

如何从C转换字符串到相应的字节数组。任何
帮助将不胜感激。
Could some C guru help me please? A byte is an unsigned char in C.
No, ''byte'' is a synonym for ''char'', which may be either signed or
unsigned. An unsigned byte is an unsigned char. Whether there is any
type that corresponds to, for example, an octet depends upon the
implementation.
How do I convert from a C string to a corresponding byte array. Any
help would be greatly appreciated.




AC字符串*是*一个以零结尾的字节数组。


char foo [] =" a string" ;;


foo是一个字符串和一个包含

{''a'的字符(或字节)数组','''','s'','t'',''r'',''我',''n'',''g'',0}



A C string *is* a zero-terminated byte array.

char foo[] = "a string";

foo is a string and a char (or byte) array containing
{''a'', '' '', ''s'', ''t'', ''r'', ''i'', ''n'', ''g'', 0}


Martin Ambuhl写道:
Martin Ambuhl wrote:
cp**********@yahoo.com 写道:
cp**********@yahoo.com wrote:
一些C大师可以帮助我吗?字节是C中的无符号字符。
Could some C guru help me please? A byte is an unsigned char in C.



不,''byte''是''char''的同义词,可以是有符号的,也可以是无符号的。无符号字节是无符号字符。是否有任何
类型对应于,例如,一个八位字节取决于
实现。



No, ''byte'' is a synonym for ''char'', which may be either signed or
unsigned. An unsigned byte is an unsigned char. Whether there is any
type that corresponds to, for example, an octet depends upon the
implementation.




什么?我离开太久了吗?我认为char是一个实体价值,但不一定是一个类似于一个字节的实体。也许

我错过了标准......:D


-atl-

-

多元宇宙是其自身创作的虚构



What? Have I been away too long? I thought that a char is an entity
of value, but not necessarily one that resembles a byte. Maybe
I''ve missed a standard... :D

-atl-
--
A multiverse is figments of its own creations


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

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