7.7写一个函数,将一个字符串中的元音字母复制到另一字符串中,然后输出。

//C程序设计第四版(谭浩强)
//章节:第七章 用函数实现模块化程序设计
//题号:7.7
//题目:写一个函数,将一个字符串中的元音字母复制到另一字符串中,然后输出。
#include <stdio.h>
#include <string.h>
void my_strcpy(char s1[])
{
	char s2[50],ch;
	int i,j=0,len=strlen(s1);
	for(i=0;i<len;i++)
	{
		if(s1[i]=='a'||s1[i]=='A'||s1[i]=='e'||s1[i]=='E'||s1[i]=='i'||s1[i]=='I'||s1[i]=='o'||s1[i]=='O'||s1[i]=='u'||s1[i]=='U')
			s2[j++]=s1[i];
	}
	s2[j]='\0';
	printf("after string copy:\n");
	puts(s2);
}
int main()
{
	char s1[50];
	printf("input string:\n");
	gets(s1);
	my_strcpy(s1);
	return 0;
 } 

猜你喜欢

转载自blog.csdn.net/weixin_44589540/article/details/86621523
今日推荐