❶ c语言中如何判断字符长度
使用string库函数里的strlen函数即可判断字符长度。
strlen函数可以计算给定字符串的长度,返回值为长度值。
例如计算字符串“helloworld2017”的长度的代码:
#include<stdio.h>
#include<string.h>
intmain()
{
inti;
i=strlen("helloworld2017");
printf("%d",i);
}
运行结果如下:
❷ C语言问题输入几个字符,怎么判断输入的是几个字符
一般都要约定一个结束标记的
比如 以换行作为结束
或者以#作为结束
或者 以EOF作为结束等等
如果不约定结束 那么是没办法知道是否输入完毕的。
❸ 如何用c语言判断一串字符中有几个是数字几个是字母
#include<stdio.h>
externintsystem(constchar*);
intmain()
{
voidsqu(char*str,int*p1,int*p2);
intmatchNum(char*s);
intmatchLetter(char*s);
inta=0,b=0;
charinput[50];
printf("Pleaseinputastring... ");
gets(input);
squ(input,&a,&b);
printf("Thereare%dnumber(s)and%dletter(s)above. ",a,b);
system("pause");
return0;
}
voidsqu(char*str,int*p1,int*p2)
{
for(;;){
if(*str=='