diff options
| author | David Faulkner <[email protected]> | 2026-08-07 23:40:47 -0500 |
|---|---|---|
| committer | David Faulkner <[email protected]> | 2026-08-07 23:40:47 -0500 |
| commit | b3e9e62599532050fc776c5e8f076915b56c2235 (patch) | |
| tree | af252346106a61b18cc6fc6fdbd32e962d096f1c /getting-started.c | |
Import official C23 code examples for Modern C (Jens Gustedt, 2024)HEADupstream-importmain
- Add official C source files, Makefile, c23-fallback.h, and LICENSE
- Update README.md with study mirror notice
Diffstat (limited to 'getting-started.c')
| -rw-r--r-- | getting-started.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/getting-started.c b/getting-started.c new file mode 100644 index 0000000..ba43f92 --- /dev/null +++ b/getting-started.c @@ -0,0 +1,24 @@ +/* This may look like nonsense, but really is -*- mode: C -*- */ +#include <stdlib.h> /*@\label{include-stdlib}*/ +#include <stdio.h> /*@\label{include-stdio}*/ + +/* The main thing that this program does. */ /*@\label{C-comment}*/ +int main(int argc, [[maybe_unused]] char* argv[argc+1]) { /*@\label{main-start}*/ + // Declarations + double A[5] = { /*@\label{array-declaration}*/ + [0] = 9.0, /*@\label{designated-init}*/ + [1] = 2.9, + [4] = 3.E+25, /*@\label{scientific-notation}*/ + [3] = .00007, /*@\label{comma-terminate}*/ + }; + + // Doing some work /*@\label{CPP-comment}*/ + for (size_t i = 0; i < 5; ++i) { /*@\label{for-loop}*/ + printf("element %zu is %g, \tits square is %g\n", /*@\label{printf-start}*/ + i, + A[i], + A[i]*A[i]); /*@\label{printf-end}*/ + } /*@\label{for-end}*/ + + return EXIT_SUCCESS; /*@\label{main-return}*/ +} /*@\label{main-end}*/ |
