Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <ctype.h>
- #include <string.h>
- #define MAX_LEN 1000
- int i;
- int check_vowel(char a)
- {
- //printf("%s %c\n", __FUNCTION__, a);
- if (a >= 'A' && a <= 'Z')
- a = a + 'a' - 'A';
- if (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
- return 1;
- return 0;
- }
- char* toggleMarginalVowels(char s[]){
- int last_pos = 0;
- for(i; s[i] != '\0'; i++){
- if(check_vowel(s[i]) == 1){
- if(islower(s[i])){
- s[i] = toupper(s[i]);
- }
- else
- s[i] = tolower(s[i]);
- while(!isspace(s[i])){
- if(check_vowel(s[i]) == 1)
- last_pos = i;
- i++;
- }
- if(islower(s[last_pos])){
- s[last_pos] = toupper(s[last_pos]);
- //printf("upper* ");
- }
- else
- s[last_pos] = tolower(s[last_pos]);
- }
- }
- printf("%s \n", s);
- }
- int main()
- {
- char string[MAX_LEN] = "This is a good one";
- toggleMarginalVowels(string);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement