Bytewise reading of memory: “signed char *” vs “unsigned char *”

前端 未结 5 1463
一个人的身影
一个人的身影 2020-12-05 08:14

One often needs to read from memory one byte at a time, like in this naive memcpy() implementation:

void *memcpy(void *dest, const void *src, si         


        
5条回答
  •  误落风尘
    2020-12-05 08:37

    It depends on what you want to store in the char. A signed char gives you a range from -127 to 127 whereas an unsigned char ranges from 0 to 255.

    For pointer arithmetic it doesn't matter.

提交回复
热议问题