hey, this is an assignment for school, the total task of the program was to accept a string, print the an uppercase version ofthe same string, count the number of vowels in the string and finally copy the identified vowels to a seconday stringto be printed.
i have pretty much finished everything excpet for the copying of the vowels to the new string, i have a statement there but it doesnt od anyhting so i know thats where im going wrong. can anyone shed some light on my situation? thanks
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<ctype.h>
int main()
{
char str[50], newstr[50], vowstr[50];
int vowels=0,len,i;
for (int k=0;k<3;k++){
printf("Enter the String:\n");
gets(str);
len=strlen(str);
for(i=0;i<len;i++){
int loc=0;
for (int j=0;j< strlen(str); j++){
newstr[loc] = toupper(str[j]);
loc++;
newstr[loc] = '\0';
}
if(str[i]=='a'||str[i]=='A'||str[i]=='e'||str[i]=='E'||str[i]=='i'||str[i]=='I'||str[i]=='o'||str[i]=='O'||str[i]=='u'||str[i]=='U'){ //checking if it is vowel or not
vowstr[i] = str[i];
vowels++;
}
}
printf("\nThe uppercase version is : %s \n", newstr);
printf("\nTotal number of vowels : %d \n\n",vowels);
printf("the vowels encountered are : %s\n\n",vowstr);
}
getchar();
return 0;
}