Convert array of char[] to byte[] and vice versa? C++

前端 未结 4 845
谎友^
谎友^ 2020-12-31 07:12

What is the best way to convert an array of chars to bytes and vice versa?

Solution:

void CharToByte(char* chars, byte* bytes, unsigned int count){
          


        
4条回答
  •  时光取名叫无心
    2020-12-31 07:18

    There is no byte type in C++, and according to the Standard:

    Edit:

    1.7:

    A byte is at least large enough to contain any member of the basic execution character set and is composed of a contiguous sequence of bits, the number of which is implementation-defined.

    5.3.3:

    sizeof(char), sizeof(signed char) and sizeof(unsigned char) are 1; the result of sizeof applied to any other fundamental type (3.9.1) is implementation-defined.

提交回复
热议问题