47 lines
745 B
C++
47 lines
745 B
C++
/*
|
|
Nome: Mario
|
|
Cognome: Montanari
|
|
Classe: 3AIN
|
|
Data: 07/03/2025
|
|
|
|
es4C: Scrivere una funzione che, ricevuta una
|
|
stringa, cancelli i caratteri corrispondenti alle
|
|
cifre che compaiono nella stringa stessa.
|
|
Prototipo richiesto:
|
|
char *deldigits(char * const str);
|
|
Esempio: "25dic2018" ? "dic"
|
|
*/
|
|
|
|
#include <iostream>
|
|
#include <cctype>
|
|
|
|
#define SIZE 100+1
|
|
|
|
using namespace std;
|
|
|
|
char *deldigits(char * const str);
|
|
|
|
int main(void) {
|
|
char str[SIZE];
|
|
|
|
cin.getline(str, SIZE);
|
|
|
|
cout << deldigits(str);
|
|
|
|
return 0;
|
|
}
|
|
|
|
char *deldigits(char * const str) {
|
|
int j = 0;
|
|
|
|
for (int i = 0; str[i] != '\0'; i++) {
|
|
if (!isdigit(str[i])) {
|
|
str[j] = str[i];
|
|
j++;
|
|
}
|
|
}
|
|
|
|
str[j] = '\0';
|
|
|
|
return str;
|
|
} |