C language: write a function to copy the vowels in two strings to another string, and then output

Topic description

Write a function that copies vowels from two strings to another, and outputs them.

enter

one line string

output

Sequentially output the vowels in it (aeiuo)

sample input

abcde

Sample output

ae 

encoding:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>  
  
char str1[100];  
char str2[100];  
char str[6] = {'a' , 'e' , 'i' , 'o' , 'u'};  
intmain()  
{  
    while(gets(str1) != NULL)  
    {  
        int i = 0;  
        int k = 0,j;  
        int len = strlen(str1);  
        while(i < len)  
        {  
            for( j = 0 ;j < 5;j++)  
                if(str1[i] == str[j])  
                {  
                    str2[k++] = str1[i];  
                    break;  
                }  
            i++;  
        }  
        puts(str2);  
    }  
    return 0;  
}  
 

  

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324838180&siteId=291194637