c++ - C Struct with uint8 array weird behavior -


i have problem following c struct:

typedef struct anchorpixel{     int32 x;     int32 y;     uint8 ch[5]; } anchorpixel; 

actually, have problem ch array inside it. cannot manipulate ch array. example, following program

anchorpixel a; a.ch[2] = 5; cout << a.ch[2]; 

gives output:

if change ch type uint8 int32, problem disappears. works:

typedef struct anchorpixel{         int32 x;         int32 y;         int32 ch[5];      } anchorpixel; 

any ideas?

it seems uint8 typedef'ed unsigned char, can see on coliru uint8_t case. cstdint header includes stdint.h , there uint8_t indeed typedef unsigned char:

typedef unsigned char       uint8_t; 

the output seeing consistent cout treating a.ch[2] char type,


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -