이 유형의 값을 저장하는 것이 처음입니다. 헤더 필드 값이 거의 없습니다. 2bit = 2, 1bit = 1, 1 비트 = 0, 4bit = 13. 순서에 따라 어떻게 uint8에 저장할 수 있습니까? 도와주세요.2 비트, 1 비트, 1 비트 및 4 비트 값을 1 바이트 정수로 저장하는 방법
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
int main(void) {
uint8_t m;
uint8_t one, two, three, four;
one = 2;
two = 1;
three = 1;
four = 13;
// do not know how to store,
//assuming m is stored
one = (m >> 7) & 1;
two = (m >> 5) & 3;
three = (m >> 4) & 1;
four = m & 15;
printf("first %i , second %i, third %i, four %i", one, two, three, four);
return 0
}
HTTP : //www.catb합니다. org/esr/structure-packing / – gj13