From 4b0fdef63fdf14c4aecafbad366a788a792e7ee3 Mon Sep 17 00:00:00 2001 From: wandoubaba517 Date: Tue, 5 Dec 2023 20:13:22 +0800 Subject: [PATCH] praise2.c --- c04_string/praise2.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 c04_string/praise2.c diff --git a/c04_string/praise2.c b/c04_string/praise2.c new file mode 100644 index 0000000..fe6818c --- /dev/null +++ b/c04_string/praise2.c @@ -0,0 +1,19 @@ +/* praise2.c */ +// 如果编译器不识别%zd,尝试换成%u或%lu +#include +#include +#define PRAISE "You are an extraordinary being." + +int main(void) +{ + char name[40]; + + printf("What's your name? "); + scanf("%s", name); + printf("Hello, %s. %s\n", name, PRAISE); + printf("Your name of %zd letters occupies %zd memory cells.\n", strlen(name), sizeof(name)); + printf("The phrase of praise has %zd letters", strlen(PRAISE)); + printf("and occupies %zd memory cells.\n", sizeof(PRAISE)); + + return 0; +} \ No newline at end of file