-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initialize members with no desginators
- Loading branch information
Showing
7 changed files
with
108 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
int main() { | ||
struct ss; | ||
|
||
struct birth { | ||
int date; | ||
int month; | ||
int year; | ||
}; | ||
|
||
struct birth bd1 = {3, 5, 1998}; | ||
|
||
__builtin_print(bd1.date); | ||
__builtin_print(bd1.month); | ||
__builtin_print(bd1.year); | ||
|
||
bd1.date = bd1.date + 2; | ||
__builtin_print(bd1.date); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
3 | ||
5 | ||
1998 | ||
5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
int main() { | ||
union u; | ||
|
||
union shape { | ||
int square; | ||
int circle; | ||
int triangle; | ||
}; | ||
|
||
// It's a legal case, but compilers like GCC may show warning of excessing elements. | ||
// The value of the members is 3. | ||
union shape s = {3, 4, 5}; | ||
|
||
// Every member shares the same starting memory address, so their value are the same. | ||
__builtin_print(s.square); | ||
__builtin_print(s.circle); | ||
__builtin_print(s.triangle); | ||
|
||
s.circle = 4; | ||
__builtin_print(s.square); | ||
__builtin_print(s.circle); | ||
__builtin_print(s.triangle); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
3 | ||
3 | ||
3 | ||
4 | ||
4 | ||
4 |