
下面给两个判断整型数据位数的函数:
1.
直接求int类型数据位数:
int
getlength(const
int
tmp)
{
int
count=0
while(
tmp/10
)
count++
return
count
}
2.
利用字符数组来变通的获取:
int
getlength(const
int
tmp)
{
char
str[16]
memset(str,
0,
sizeof(str))
sprintf(str,
"%d",
tmp)
return
strlen(str)
}
#include<stdio.h>#include<string.h>
#include<ctype.h>
int main()
{
int i
char a[100]={0}
gets(a)
a[0]=toupper(a[0])
for(i=1i<strlen(a)i++)
{
if(a[i-1]==' ')
{
a[i]=toupper(a[i])
}
else
}
printf("%s\n",a)
}
我加了个等于应该就行了!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)