最近在做一個簡單的按鍵檢測,定義一個uint8_t的函數,函數作用是返回一個按鍵編號數字。
函數返回值 return 1/2/3/4,代表4個按鍵
但是按鍵檢測結果卻是錯誤的!!!
百思不得其解,后來明白了,原來uint8_t相當於 char
typedef unsigned char uint8_t;
typedef unsigned short int uint16_t;
typedef unsigned int uint32_t;
應當return '1'/'2';