/*
Nome: Mario
Cognome: Montanari

dupDigit
*/

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

#define SIZE 100+1

using namespace std;

char *dupDigit(char *const str);

int main(void) {
	char str[SIZE] = "H3ll0 W0rld! 2025";
	
	cout << "Before: " << str << endl;
	
	dupDigit(str);
	
	cout << "After: " << str << endl;
	
	return 0;
}

// Con puntatori
char *dupDigit(char *const str) {
	for (char *r = str; *r != '\0'; r++) {
		if (isdigit(*r)) {
			memmove(r + 1, r, strlen(r) + 1);
			r = r + 1;
		}
	}
	
	return str;
}

/* Senza puntatori
char *dupDigit(char *const str) {
	for (int i = 0; str[i] != '\0'; i++) {
		if (isdigit(str[i])) {
			memmove(&str[i + 1], &str[i], strlen(&str[i]) + 1);
			i = i + 1;
		}
	}
	
	return str;
}
*/