Other types of array elements must be the same size as uint16_t
, so just drop them. In the case of 8-bit data, there is a possibility that the upper 8 bits will be undefined, so I hid them.
#include <stdio.h> #define uint16_t unsigned short #define int16_t short #define uint8_t unsigned char int main() { uint16_t n; // convert uint16_t to int16_t n = 0xFFFF; printf ("%d\n", (int16_t)n); // convert uint16_t to uint8_t n = 168; printf ("%c\n", (uint8_t)(n & 0xFF)); return 0; }
Program exit
-1 ¿
source share