#include <stdio.h>
int main()
{
char str[101];
int len;
printf("enter a string: "); fflush(stdout);
if(scanf("%100s", str) == 1) {
printf("the length of the string \"");
len = printf("%s", str);
printf("\" is %d\n", len);
}
}
Another possibility (though not quite exactly filling in your blanks) is:
#include <stdio.h>
int main()
{
char str[101];
int len;
printf("enter a string: "); fflush(stdout);
if(scanf("%100s", str) == 1) {
printf("the length of the string \"");
len = printf("%s", str);
printf("\" is %d\n", len);
}
}
发布评论
评论(2)
看来您需要的是以下内容
请注意,使用名称
strlen
作为与标准字符串函数strlen
对应的变量是一个坏主意。It seems what you need is the following
Pay attention to that using the name
strlen
for the variable that corresponds to the standard string functionstrlen
is a bad idea.另一种可能性(虽然不能完全填补你的空白)是:
Another possibility (though not quite exactly filling in your blanks) is: