39 lines
552 B
C++
39 lines
552 B
C++
/*
|
|
Nome: Mario
|
|
Cognome: Montanari
|
|
Classe: 3AIN
|
|
Data: 07/03/2025
|
|
|
|
es01: scrivi una implementazione dellafunzione di
|
|
libreria su stringhe che ritornano la sua lunghezza
|
|
*/
|
|
|
|
#include <iostream>
|
|
|
|
#define SIZE 100+1
|
|
|
|
using namespace std;
|
|
|
|
void lenStr(char *str);
|
|
|
|
int main(void) {
|
|
char str[SIZE];
|
|
|
|
cin.getline(str, SIZE);
|
|
|
|
lenStr(str);
|
|
|
|
return 0;
|
|
}
|
|
|
|
void lenStr(char *str) {
|
|
int contaChr = 0;
|
|
|
|
for (int i = 0; str[i] != '\0'; i++) {
|
|
if (str[i] != '\0') {
|
|
contaChr++;
|
|
}
|
|
}
|
|
|
|
cout << contaChr << endl;
|
|
} |