- #include<string.h>
- #include<ctype.h>
- void copyif(char str1[30], char str2[30])//复制元音字母的函数
- {
- int i, j;
- char str;
- for (i = 0, j = 0; str1[i] != '\0' && i < 30; i++)
- {
- str = tolower(str1[i]);
- if (str == 'a' || str == 'e' || str == 'i' || str == 'o' || str == 'u')
- str2[j++] = str1[i];
- }
- str2[j] = '\0';
- }
- void main()
- {
- void copyif(char str1[30], char str2[30]);
- char str1[30] = { '\0' }, str2[30] = { '\0' };
- gets(str1);//输入原字符串
- copyif(str1, str2);//调用复制元音字母的函数
- puts(str2);//输出新字符串
- }