C语言代码:提取字符串中的元音字母并复制到新字符串
#include <stdio.h> #include <string.h>
void Yuan_Word(char s[], char cpy[]) { int j = 0; for (int i = 0; s[i] != '\0'; ++i) { if(s[i] == 'A' || s[i] == 'a' || s[i] == 'E' || s[i] == 'e' || s[i] == 'I' || s[i] == 'i' || s[i] == 'O' || s[i] == 'o' || s[i] == 'U' || s[i] == 'u') { printf('%c ', s[i]); cpy[j] = s[i]; j++; } } printf("\n"); cpy[j] = '\0'; }
int main() { char a[32] ={'abcdef'}; char b[32]; Yuan_Word(a, b); puts(b); return 0; }
原文地址: https://www.cveoy.top/t/topic/ndax 著作权归作者所有。请勿转载和采集!