是因为’\0’吗?
输出的时候puts()不行是错误50,
#include<stdio.h>
#include<string.h>
int vowels(char *s1, char *s2);
int main(){
int i = 0;
char s1[10], s2[10];
gets(s1);
int len = vowels(s1, s2);
for(i = 0; i < len; i++){
printf("%c", s2[i]);
}
printf("\n");
return 0;
}
int vowels(char *s1, char *s2){
int i = 0;
int j = 0;
int len = strlen(s1);
for(i = 0; i < len; i++){
if(s1[i] == 'a' || s1[i] == 'e' || s1[i] == 'i' || s1[i] == 'o' || s1[i] == 'u'
|| s1[i] == 'A' || s1[i] == 'E' || s1[i] == 'I' || s1[i] == 'O' || s1[i] == 'U'
){
s2[j] = s1[i];
j++;
}
}
return j;
}