函数fun的功能是:将s所指字符串中ASCII值为奇数的字符删除,串中剩余字符形成一个新的串放在t所指的数组中。
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>
void fun(char *s, char t[])
{
int i = 0, j = 0;
while (s[i])
{
if (s[i] % 2 == 0)
t[j++] = s[i];
i++;
}
t[j] = 0;
}
int main()
{
char s[100], t[100];
printf("\nPlease enter string S:");
scanf("%s", s);
fun(s, t);
printf("\nThe result is :%s\n", t);
getchar();
getchar();
return 0;
}