31 lines
422 B
C
31 lines
422 B
C
/* strlen */
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
|
|
int strlength(char*);
|
|
|
|
int main() {
|
|
char mot[100];
|
|
int i = 0;
|
|
|
|
printf("Ecrire un mot : ");
|
|
fgets(mot, 100, stdin);
|
|
while (mot[i] != '\n') i++;
|
|
mot[i] = '\0';
|
|
|
|
printf("Taille de la string : %d\n", strlength(mot));
|
|
|
|
return 0;
|
|
}
|
|
|
|
int strlength(char *mot) {
|
|
int i = 0;
|
|
|
|
while (mot[i] != '\0') {
|
|
i++;
|
|
}
|
|
|
|
return i;
|
|
}
|