程序如下:
#include <stdio.h> #include <stdlib.h> struct bitint { int a:2; int b:2; int c:1; }; int main() { struct bitint test; test.a = 1; test.b = 3; test.c = 1; printf("a is %d b is %d c is %d\n", test.a, test.b, test.c); return 0; }
結果為:
v0id@ubuntu:~/test$ ./a.out
a is 1 b is -1 c is -1