#include <stdio.h> #include <string.h> #define PRAISE "what a super marvelous name! " int main(void) { char name[50]; printf("what‘s your name?\n"); scanf("%s",name); printf("hello,%s.%s\n",name,PRAISE); printf("you name of %d letters occupies %d memory calls.\n", strlen (name),sizeof (name)); printf("the phrase of praise has %d letters", strlen (PRAISE)); printf("and occupies %d memory cell.\n\n\n\n",sizeof PRAISE); printf("%s",name); return 0; }
一开始以为哪输错了,后开试了一下才知道空格代表结束,还有 系统会自动补全字符
原文:http://www.cnblogs.com/zhanghuanqiao/p/4960044.html