- Timestamp:
- Oct 26, 2024, 6:48:38 PM (3 weeks ago)
- Branches:
- master
- Children:
- bf91d1d
- Parents:
- 06d75931
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/mike_brooks_MMath/programs/bkgd-carray-arrty.c
r06d75931 r14c31eb 57 57 f( &ar ); 58 58 59 float fs []= {3.14, 1.77};60 char cs [] = "hello";59 float fs@[]@ = {3.14, 1.77}; 60 char cs@[]@ = "hello"; // shorthand for 'h', 'e', 'l', 'l', 'o', '\0' 61 61 static_assert( sizeof(fs) == 2 * sizeof(float) ); 62 62 static_assert( sizeof(cs) == 6 * sizeof(char) ); $\C{// 5 letters + 1 null terminator}$ 63 63 64 float fm[] [2]= { {3.14, 1.77}, {12.4, 0.01}, {7.8, 1.23} }; $\C{// brackets define structuring}$65 char cm[] [sizeof("hello")]= { "hello", "hello", "hello" };64 float fm[]@[2]@ = { {3.14, 1.77}, {12.4, 0.01}, {7.8, 1.23} }; $\C{// brackets define structuring}$ 65 char cm[]@[sizeof("hello")]@ = { "hello", "hello", "hello" }; 66 66 static_assert( sizeof(fm) == 3 * 2 * sizeof(float) ); 67 67 static_assert( sizeof(cm) == 3 * 6 * sizeof(char) );
Note: See TracChangeset
for help on using the changeset viewer.