参考代码:
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>
#include<assert.h>
void Changestring(char *dest,char*res)
{
assert(dest && res);//多用assert,增强健壮性,避免传入空指针
int sz = strlen(res);
int j = 0;//标记dest中当前的元素
for (int i = 0; i < sz; i++)
{
if (res[i] == 'a' || res[i] == 'A' ||
res[i] == 'e' || res[i] == 'E' ||
res[i] == 'i' || res[i] == 'I' ||
res[i] == 'o' || res[i] == 'O' ||
res[i] == 'u' || res[i] == 'U')
{
dest[j] = res[i];
j++;
}
}
}
int main()
{
char arr[30] = {0};
char input[30] = {0};
gets(arr);//vs环境下需要改成gets_s
Changestring(input, arr);
printf("%s\n", input);
return 0;
}
0.0分
1 人评分
字符串问题 (C语言代码)浏览:1519 |
C语言训练-排序问题<1> (C语言代码)浏览:601 |
C语言程序设计教程(第三版)课后习题6.9 (C语言代码)浏览:543 |
A+B for Input-Output Practice (III) (C语言代码)浏览:576 |
WU-字符串比较 (C++代码)浏览:756 |
简单的a+b (C语言代码)浏览:577 |
Cylinder (C语言描述+详细分析)浏览:3265 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:531 |
钟神赛车 (C语言代码)浏览:598 |
交换Easy (C语言代码)浏览:761 |