I'm trying to remove the vowels from the userInput array and copy the rest to the newString array. I thought looping through the userInput and assigning it to newStrin would work but im only getting the first character of newString array. I can see that on the iteration where i = 2, 't' should be assigned to newString[2] but when I attempt to print the array back in main it only prints the first character.
void removeVowels( char newString [], char userInput []){
int i = 0;
while ( i < myStrlen(userInput)) {
if ( (userInput[i] != 'a')&&
(userInput[i] != 'e')&&
(userInput[i] != 'i')&&
(userInput[i] != 'o')&&
(userInput[i] != 'u')){
newString[i] = userInput[i];
cout << newString[i] << endl;
}
i++;
}
}
My output:
c
t
cat without vowels is: c
Expected output:
c
t
cat without vowels is: ct