【CPP】字符串和格式化输入输出
#include
#include<string.h>//提供strlen()函数的原型 ,他包含了许多与字符串相关的函数的原型 #definePRAISE "what a marvelous name!"intmain(void)
{
charname[40];
printf("what‘s your name?\n");
scanf("%s",name);
printf("Hello %s !",name);
printf("your name of %d letters occupies %d memory cells.\n",strlen(name),sizeof name );
printf("the phrase of praise has %d letters.\n",strlen(PRAISE));
printf("and occupies %d memory cells.\n",sizeof PRAISE );
return0;
}
来源: http://www.bubuko.com/infodetail-2140850.html