I wanted to put some small integers in an array and decided to use int8_t:
#include <cstdint>
#include <iostream>
int main() {
int n = 3;
int8_t arr[n];
for (int i = 0; i < n; ++i) {
std::cin >> arr[i];
}
}
Enter 9 -20 14and n = 3.
But instead 9, -20, 14in the array I got 9, -, 2.
Why int8_tdoes it act like char?
PS int8_ttypedef'd sys/types.has follows:
# define __intN_t(N, MODE) \
typedef int int##N##_t __attribute__ ((__mode__ (MODE)))
# ifndef __int8_t_defined
# define __int8_t_defined
__intN_t (8, __QI__);
# endif
source
share