两个c语言的问题~

来源:百度知道 编辑:UC知道 时间:2024/09/19 21:02:00
1、实现strlen函数功能(数字符串长度)
用逐个字符输入一个字符串,必须用数组,统计字符个数,输出字符个数。
2、实现strlwr函数功能(将大写字母转换成小写字母)
用整体方式输入一个字符串、数组,将数组中大写字母转换成小写字母,其他字母保持不变,输出转换后的字符串。
高手速度帮忙哈~~要交作业的,别直接copy别处的~~~是用Tc编程,呃,别出现中文。。。。拜托了~~~~

#include <stdio.h>
int main()
{
char s[100],c;
int i=-1,j,k;
while(c=getchar()!='\n')
s[++i]=c;
printf("%d\n",i+1);
return 0;
}

#include <stdio.h>
#include<string.h>
void strlw(char s[100])
{
int k=strlen(s),i;
for(i=0;i<k;i++)
if(s[i]>='A'&&s[i]<='Z')
s[i]+=32;

}
int main()
{
char s[100];
scanf("%s",s);
strlw(s);
puts(s);
return 0;
}

等一下

1.
#include <stdio.h>
int len_str()
{
int i;
char s[128];
for(i=0,s[i]=getchar();1;s[++i]=getchar())
if(s[i]==10)
{
s[i]='\0';
break;
}
rintf("the length of the string is %d!",i+1);
}
int main()
{
len_str();
}

2.
#include <stdio.h>
#include <string.h><