praise2.c
This commit is contained in:
parent
4b0fdef63f
commit
e24f03e91d
@ -1,5 +1,7 @@
|
|||||||
/* praise2.c */
|
/* praise2.c */
|
||||||
// 如果编译器不识别%zd,尝试换成%u或%lu
|
// 如果编译器不识别%zd,尝试换成%u或%lu
|
||||||
|
// 在gcc version 10.2.1 20210110 (Debian 10.2.1-6)环境中
|
||||||
|
// %zd统一换成%d得到的结果是一致的
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#define PRAISE "You are an extraordinary being."
|
#define PRAISE "You are an extraordinary being."
|
||||||
@ -10,6 +12,12 @@ int main(void)
|
|||||||
|
|
||||||
printf("What's your name? ");
|
printf("What's your name? ");
|
||||||
scanf("%s", name);
|
scanf("%s", name);
|
||||||
|
printf("\n");
|
||||||
|
printf("Hello, %s. %s\n", name, PRAISE);
|
||||||
|
printf("Your name of %d letters occupies %d memory cells.\n", strlen(name), sizeof(name));
|
||||||
|
printf("The phrase of praise has %d letters", strlen(PRAISE));
|
||||||
|
printf("and occupies %d memory cells.\n", sizeof(PRAISE));
|
||||||
|
printf("\n");
|
||||||
printf("Hello, %s. %s\n", name, PRAISE);
|
printf("Hello, %s. %s\n", name, PRAISE);
|
||||||
printf("Your name of %zd letters occupies %zd memory cells.\n", strlen(name), sizeof(name));
|
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("The phrase of praise has %zd letters", strlen(PRAISE));
|
||||||
|
Loading…
Reference in New Issue
Block a user