char 和 unsigned char 有什么区别? [英] What is the difference between char and unsigned char?

查看:29
本文介绍了char 和 unsigned char 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(已编辑将 C/C++ 更改为 C)

请帮我找出一个关于C中charunsigned char的清晰说明.特别是当我们在嵌入式设备和普通PC之间传输数据时(缓冲区之间的区别unsigned char 和普通 char).

Please help me to find out a clean clarification on char and unsigned char in C. Specially when we transfer data between embedded devices and general PCs (The difference between buffer of unsigned char and plain char).

推荐答案

你问的是两种不同的语言,但在这方面,答案(或多或少)对两者都是相同的.不过,您确实应该决定使用哪种语言.

You're asking about two different languages but, in this respect, the answer is (more or less) the same for both. You really should decide which language you're using though.

区别:

  • 它们是不同的类型
  • char 是有符号还是无符号由实现定义
  • they are distinct types
  • it's implementation-defined whether char is signed or unsigned

相似之处:

  • 它们都是整数类型
  • 它们的大小相同(一个字节,至少 8 位)

如果您只是使用它们来传输原始字节值,没有算术,那么没有实际区别.

If you're simply using them to transfer raw byte values, with no arithmetic, then there's no practical difference.

这篇关于char 和 unsigned char 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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