Skip to content

Commit 85c9f00

Browse files
committed
new file: ../structbit/main.c
new file: ../uniconbit/main.c
1 parent e4a5b01 commit 85c9f00

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

c/structbit/main.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <stdio.h>
2+
int main(){
3+
struct test {
4+
unsigned int a:1;
5+
unsigned int b:2;
6+
unsigned int c:1;
7+
};
8+
struct test test2;
9+
test2.a=3;
10+
test2.b=1;
11+
test2.c=-1;
12+
printf("%d\n%d\n%d\n",test2.a,test2.b,test2.c);
13+
}

c/uniconbit/main.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include <stdio.h>
2+
int main(){
3+
union test {
4+
unsigned int a:1;
5+
unsigned int b:2;
6+
unsigned int c:1;
7+
};
8+
union test test2;
9+
test2.a=1;
10+
printf("%d\n",test2.a);
11+
}

0 commit comments

Comments
 (0)