praise2.c
This commit is contained in:
parent
f87ca1a047
commit
4b0fdef63f
19
c04_string/praise2.c
Normal file
19
c04_string/praise2.c
Normal file
@ -0,0 +1,19 @@
|
||||
/* praise2.c */
|
||||
// 如果编译器不识别%zd,尝试换成%u或%lu
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user