A-A+

以下程序的功能是计算字符串的长度。请填空。#include<stdio.h>main(){c

2022-08-06 10:52:29 问答库 阅读 178 次

问题详情

以下程序的功能是计算字符串的长度。请填空。
#include<stdio.h>
main()
{char str[100],*sp=str;
int nlen=0;
scanf("%s",str);
for(;*sp!="";sp++)______;
printf("%d",nlen);
}

参考答案

正确答案:
nlen++ [解析] 利用字符串结束标志'\0',nlen是计数器。

考点:字符串,长度