相关疑难解决方法(0)

什么是unsigned char?

在C/C++中,unsigned char用于什么?它与常规有什么不同char

c c++ char

456
推荐指数
13
解决办法
55万
查看次数

有符号/无符号字符之间的区别

所以我知道有符号和无符号int之间的区别在于,有一些用于表示数字是正数还是负数,但这如何适用于char?角色怎样才能是积极的还是消极的?

c types

130
推荐指数
5
解决办法
23万
查看次数

char!=(signed char),char!=(unsigned char)

下面的代码编译,但char类型的行为与int类型的行为不同.

特别是

   cout << getIsTrue< isX<int8>::ikIsX  >() << endl;
   cout << getIsTrue< isX<uint8>::ikIsX  >() << endl;
   cout << getIsTrue< isX<char>::ikIsX  >() << endl;
Run Code Online (Sandbox Code Playgroud)

导致三种类型的模板的3个实例化:int8,uint8和char.是什么赋予了?

对于ints来说也是如此:int和uint32导致相同的模板实例化,而signed int则是另一个.

原因似乎是C++将char,signed char和unsigned char视为三种不同的类型.而int与signed int相同.这是对的还是我错过了什么?

#include <iostream>

using namespace std;

typedef   signed char       int8;
typedef unsigned char      uint8;
typedef   signed short      int16;
typedef unsigned short     uint16;
typedef   signed int        int32;
typedef unsigned int       uint32;
typedef   signed long long  int64;
typedef unsigned long long uint64;

struct TrueType {};
struct FalseType {};

template <typename T>
struct isX …
Run Code Online (Sandbox Code Playgroud)

c++ char

40
推荐指数
4
解决办法
2万
查看次数

签署一个字符是什么意思?

鉴于有符号和无符号整数使用相同的寄存器等,并且只是不同地解释位模式,而C字符基本上只是8位整数,C中有符号和无符号字符之间的区别是什么?我理解char的签名是实现定义的,我根本无法理解它是如何产生影响的,至少当char用于保存字符串而不是数学时.

c string signed char character-encoding

19
推荐指数
3
解决办法
3万
查看次数

`std :: string`是否将其字符作为签名字符存储在内部?

我正在写一个算法要求我将值插入到std::string无符号的1字节整数(0 - 255)中,并要求我将字符串的各个字符的值打印为整数,但是,我不断得到负值.我的猜测是,字符存储在带std::string符号的1字节字符(-128到127)中,因此,为什么我得到输出的负值.负值是我插入的正值的等效负形式.我做了一些研究,但似乎无法找到一种方式来表达我的问题,产生我正在寻找的答案.

c++ string

0
推荐指数
1
解决办法
82
查看次数

标签 统计

c ×3

c++ ×3

char ×3

string ×2

character-encoding ×1

signed ×1

types ×1