任意输入一长度不超过30的字符串,使用指针编写函数,实现如下功能:将一个字符串str1中的所有小写字母复制成为一个新的字符串str2。 例如:若str1为“progRam Cczuoye_19.”,则str2应为“progamczuoye”。
要求:在主函数中输入原始字符串,调用上述函数后,输出新的字符串。
说明:
(1)输入格式:gets()
(2)输出格式:puts()
提示性文字的输出格式:"input string:\n"
"new string is:\n"
#include<string.h>
#include<stdio.h>
void CopyString( char *s1, char *s2)
{
//int i,j;
for(;*s1!='\0';s1=s1+1)
if(*s1>='a'&&*s1<='z')
{*s2=*s1 ;
s2++;
}
*s2='\0';
}
int main()
{
char s[30],s2[20];
printf("input string:\n");
gets(s);
CopyString( s, s2);
printf("new string is:\n");
puts(s2);
return 0;
}