47 lines
760 B
C++
47 lines
760 B
C++
/*
|
|
Nome: Mario
|
|
Cognome: Montanari
|
|
Classe: 3AIN
|
|
Data: 07/03/2025
|
|
|
|
es4B: Scrivere una funzione che, ricevuta una stringa,
|
|
cancelli i caratteri corrispondenti ai caratteri
|
|
alfabetici che compaiono nella stringa stessa.
|
|
Prototipo richiesto:
|
|
char *delalphas(char * const str);
|
|
Esempio: "25dic2018" ? "252018"
|
|
*/
|
|
|
|
#include <iostream>
|
|
#include <cctype>
|
|
|
|
#define SIZE 100+1
|
|
|
|
using namespace std;
|
|
|
|
char *delalphas(char * const str);
|
|
|
|
int main(void) {
|
|
char str[SIZE];
|
|
|
|
cin.getline(str, SIZE);
|
|
|
|
cout << delalphas(str);
|
|
|
|
return 0;
|
|
}
|
|
|
|
char *delalphas(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;
|
|
} |