DEV/ControleMachine2/Exercice1.c
2023-04-27 11:27:11 +02:00

39 lines
574 B
C

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char* suppNonLettres(char* s){
int i;
for (i=0;i<255;i++){
if (s[i]<'A'){
s[i]='\a';
} if (s[i]>'Z'&& s[i]<'a'){
s[i]='\a';
} if (s[i]>'z'){
s[i]='\a';
}
} return(s);
}
int main(int argc, char const *argv[])
{
char* s=calloc(256,sizeof(char));
char c=-128;
int i;
int t;
s[0]=c;
for (i=0;i<255;i++){
c++;
s[i]=c;
} suppNonLettres(s);
printf("%s\n",s);
t=strlen(s);
for (i=t;i>=0;i--){
if (s[i]=='\a'){
t--;
}
}
printf("Cette chaine est de taille %d.\n",t);
return 0;
}