From b3e9e62599532050fc776c5e8f076915b56c2235 Mon Sep 17 00:00:00 2001 From: David Faulkner Date: Fri, 7 Aug 2026 23:40:47 -0500 Subject: Import official C23 code examples for Modern C (Jens Gustedt, 2024) - Add official C source files, Makefile, c23-fallback.h, and LICENSE - Update README.md with study mirror notice --- strcpy.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 strcpy.c (limited to 'strcpy.c') diff --git a/strcpy.c b/strcpy.c new file mode 100644 index 0000000..a34dd71 --- /dev/null +++ b/strcpy.c @@ -0,0 +1,17 @@ +#include +#include +int main(int argc, char* argv[argc+1]) { + size_t const len = strlen(argv[0]); // Computes the length + // Initialized VLA, /*@\C{23}*/ + // terminates array with 0 character + char name[len+1] = { }; + // Copies the program name + memcpy(name, argv[0], len); + if (!strcmp(name, argv[0])) { + printf("program name \"%s\" successfully copied\n", + name); + } else { + printf("copying %s leads to different string %s\n", + argv[0], name); + } +} -- cgit v1.2.3