Remove Vowels
Completed
Read a line and print it with all vowels (either case) removed, building the result in a second array.
Input
One line.
Output
One line.
Example
Input
Programming in C
Output
Prgrmmng n C
Editor
C
Hints
Copy only the characters you keep, then add '\0' at the end.
Solution explanation
Forgetting the terminating '\0' is the most common C string bug.
Show solution
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main() {
char s[200], out[200];
int k = 0;
fgets(s, 200, stdin);
s[strcspn(s, "\n")] = '\0';
for (int i = 0; s[i] != '\0'; i++) {
char c = tolower(s[i]);
if (c != 'a' && c != 'e' && c != 'i' && c != 'o' && c != 'u') {
out[k] = s[i];
k++;
}
}
out[k] = '\0';
printf("%s\n", out);
return 0;
}