![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
いろいろなテクニック.Nucleo と DISCO-F746 用.
Dependencies: Array_Matrix mbed
InitializeStruct.hpp
- Committer:
- MikamiUitOpen
- Date:
- 2017-10-15
- Revision:
- 0:bb939e0bc6e2
- Child:
- 1:bbb9f0c3e523
File content as of revision 0:bb939e0bc6e2:
// 構造体の初期化 void InitializeStruct() { struct myStruct{ int a1; int a2; }; myStruct x1 = { a1: 1, a2: 2 }; myStruct x2 = { .a1 = -3, .a2 = -4 }; myStruct x3 = { 5, 6 }; // 初期化なので OK myStruct x4; // x4 = {-7, -8}; // エラー,代入なので使えない x4 = (myStruct){-7, -8}; // 複合リテラル(compound literal)を利用 printf("\r\nx1.a1 = %d, x1.a2 = %d\r\n", x1.a1, x1.a2); printf("\r\nx2.a1 = %d, x2.a2 = %d\r\n", x2.a1, x2.a2); printf("\r\nx3.a1 = %d, x3.a2 = %d\r\n", x3.a1, x3.a2); printf("\r\nx4.a1 = %d, x4.a2 = %d\r\n", x4.a1, x4.a2); }