Simple training demonstration to show the use of typedef
Fork of StructureExample by
Diff: main.cpp
- Revision:
- 7:4753526f342a
- Parent:
- 6:5f4be4b8db14
--- a/main.cpp Tue Nov 26 11:39:57 2013 +0000 +++ b/main.cpp Tue Nov 26 11:52:54 2013 +0000 @@ -6,26 +6,13 @@ *******************************************************************************/ #include "mbed.h" -#include "USBSerial.h" -USBSerial serial; // Virtual serial port over USB. Use Teraterm as the interface - -struct coordXY { int iX; int iY; }; // Define a new structure +typedef unsigned short myword; int main() { - coordXY Position1, Position2; // Declare variables with the new structure + myword mwAddress; // Declare variables with the new type - wait (10); // Wait 10 seconds to connect port - - Position1.iX = 1; // Sets Position1.iX only - Position1.iY = 2; // Sets Position1.iY only - Position2.iX = 9; // Sets Position2.iX only - Position2.iY = 6; // Sets Position2.iY only - - serial.printf("Position1.iX:%i, Position1.iY:%i\n\r", Position1.iX, Position1.iY); - - Position1 = Position2; // Directly load Position1 from Position2 - serial.printf("Position1.iX:%i, Position1.iY:%i\n\r", Position1.iX, Position1.iY); + mwAddress = 600; for(;;) {} // Loop forever } \ No newline at end of file