/*
Nome: Mario
Cognome: Montanari

dupVowels & dupConsonants
*/

#include <iostream>
#include <cstring>
#include <cctype>
#include <iomanip>

#define SIZE 100+1

using namespace std;

bool isVowel(char c);
bool isConsonant(char c);
char *dupVowels(char *const src);
char *dupConsonants(char *const str);

int main(void) {
	char src[SIZE] = "12 ottobre 1492";
	char dst[SIZE];
	
	strcpy(dst, src);
	
	cout << "Original string: " << setw(16) << src << endl;
	
	dupVowels(src);
	cout << "dupVowels: " << setw(25) << src << endl;
	
	dupConsonants(dst);
	cout << "dupConsonants: " << setw(22) << dst << endl;
	
	return 0;
}

bool isVowel(char c) {
	return strchr("aeiou", tolower(c));
}

bool isConsonant(char c) {
	return strchr("bcdfghjklmnpqrstvwxyz", tolower(c));
}

// Con puntatori
char *dupVowels(char *const src) {
	for (int r = 0; src[r] != '\0'; r++) {
		if (isVowel(src[r])) {
			memmove(src + r + 1, src + r, strlen(src + r) + 1);
			r++;
		}
	}
	
	return src;
}

/* Senza puntatori
char *dupVowels(char *const src) {
	for (int r = 0; src[r] != '\0'; r++) {
		if (isVowel(src[r])) {
			memmove(src + r + 1, src + r, strlen(src + r) + 1);
			r++;
		}
	}
	
	return src;
}
*/


// Con puntatori
char *dupConsonants(char *const dst) {
	for (int r = 0; dst[r] != '\0'; r++) {
		if (isConsonant(dst[r])) {
			memmove(dst + r + 1, dst + r, strlen(dst + r) + 1);
			r++;
		}
	}
	
	return dst;
}

/* Senza puntatori
char *dupConsonants(char *const dst) {
	for (int r = 0; dst[r] != '\0'; r++) {
		if (isConsonant(dst[r])) {
			memmove(dst + r + 1, dst + r, strlen(dst + r) + 1);
			r++;
		}
	}
	
	return dst;
}
*/