在这里插入代码片
#include<stdio.h>
#define N 100
void main()
{
int
i=0;
char
s[N];
printf(“请输入字符串:”);
gets(s);
while(s[i]!=’\0’)
i++;
printf(“字符串:”);
puts(s);
printf(“字符串长度length=%d”,i);
printf("\n");
}
本文介绍了一个使用C语言实现的简单程序,该程序用于获取用户输入的字符串并计算其长度。通过while循环遍历字符串直到遇到空字符,程序能够准确地统计出字符串中字符的数量。
在这里插入代码片
#include<stdio.h>
#define N 100
void main()
{
int
i=0;
char
s[N];
printf(“请输入字符串:”);
gets(s);
while(s[i]!=’\0’)
i++;
printf(“字符串:”);
puts(s);
printf(“字符串长度length=%d”,i);
printf("\n");
}
您可能感兴趣的与本文相关的镜像
HunyuanVideo-Foley
HunyuanVideo-Foley是由腾讯混元2025年8月28日宣布开源端到端视频音效生成模型,用户只需输入视频和文字,就能为视频匹配电影级音效

被折叠的 条评论
为什么被折叠?