← Back to davo.co
summaryrefslogtreecommitdiffstats
path: root/tendots.c
diff options
context:
space:
mode:
authorDavid Faulkner <[email protected]>2026-08-07 23:40:47 -0500
committerDavid Faulkner <[email protected]>2026-08-07 23:40:47 -0500
commitb3e9e62599532050fc776c5e8f076915b56c2235 (patch)
treeaf252346106a61b18cc6fc6fdbd32e962d096f1c /tendots.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 'tendots.c')
-rw-r--r--tendots.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/tendots.c b/tendots.c
new file mode 100644
index 0000000..0733747
--- /dev/null
+++ b/tendots.c
@@ -0,0 +1,25 @@
+#include <stdio.h>
+
+/* delay execution with some crude code,
+ should use thrd_sleep, once we have that */
+void delay(double secs) {
+ double const magic = 4E8; // works just on my machine
+ unsigned long long const nano = secs * magic;
+ for (unsigned long volatile count = 0;
+ count < nano;
+ ++count) {
+ /* nothing here */
+ }
+}
+
+int main(int argc, [[maybe_unused]] char* argv[argc+1]) {
+ fputs("waiting 10 seconds for you to stop me", stdout);
+ if (argc < 3) fflush(stdout);
+ for (unsigned i = 0; i < 10; ++i) {
+ fputc('.', stdout);
+ if (argc < 2) fflush(stdout);
+ delay(1.0);
+ }
+ fputs("\n", stdout);
+ fputs("You did ignore me, so bye bye\n", stdout);
+}