Simple training demonstration to show the use of union
Fork of TypedefExample by
main.cpp@7:4753526f342a, 2013-11-26 (annotated)
- Committer:
- jf1452
- Date:
- Tue Nov 26 11:52:54 2013 +0000
- Revision:
- 7:4753526f342a
- Parent:
- 6:5f4be4b8db14
- Child:
- 8:c0d351fc572f
Typedef Example
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jf1452 | 1:d9da28105bef | 1 | /******************************************************************************* |
jf1452 | 6:5f4be4b8db14 | 2 | * This program demonstrates the use of structures * |
jf1452 | 1:d9da28105bef | 3 | * * |
jf1452 | 1:d9da28105bef | 4 | * Jon Fuge * |
jf1452 | 2:db81cad8cb64 | 5 | * V1.0 25/11/2013 First issue of code * |
jf1452 | 1:d9da28105bef | 6 | *******************************************************************************/ |
dan | 0:7dec7e9ac085 | 7 | |
jf1452 | 2:db81cad8cb64 | 8 | #include "mbed.h" |
jf1452 | 3:0f80147842c2 | 9 | |
jf1452 | 7:4753526f342a | 10 | typedef unsigned short myword; |
jf1452 | 6:5f4be4b8db14 | 11 | |
dan | 0:7dec7e9ac085 | 12 | int main() { |
jf1452 | 7:4753526f342a | 13 | myword mwAddress; // Declare variables with the new type |
jf1452 | 5:eb5c6ae5938b | 14 | |
jf1452 | 7:4753526f342a | 15 | mwAddress = 600; |
jf1452 | 6:5f4be4b8db14 | 16 | |
jf1452 | 6:5f4be4b8db14 | 17 | for(;;) {} // Loop forever |
jf1452 | 3:0f80147842c2 | 18 | } |