Le C++ baisser() La fonction convertit un alphabet majuscule en alphabet minuscule. C'est une fonction prédéfinie de ctype.h En tête de fichier. Si le caractère transmis est un alphabet majuscule, alors la fonction tolower() convertit un alphabet majuscule en alphabet minuscule. Cette fonction n'affecte pas les autres caractères minuscules, symboles spéciaux ou chiffres.
int tolower(int ch);>
Paramètre:
- ch : C'est le caractère à convertir en minuscule.
Valeur de retour : Cette fonction renvoie la valeur ASCII du caractère minuscule correspondant à la ch.
En C++, le transtypage de int en char se fait comme suit :
char c = (char) tolower('A');> Les programmes ci-dessous illustrent la fonction tolower() en C++ :
Exemple 1:
C++
âge de Rihanna
// C++ program to demonstrate> // example of tolower() function.> > #include> using> namespace> std;> > int> main()> {> > >char> c =>'G'>;> > >cout << c <<>' in lowercase is represented as = '>;> > >// tolower() returns an int value there for typecasting> >// with char is required> >cout << (>char>)>tolower>(c);> }> |
>
>Sortir
G in lowercase is represented as = g>
Exemple 2 :
C++
// C++ program to convert a string to lowercase> // using tolower> #include> using> namespace> std;> > int> main()> {> > >// string to be converted to lowercase> >string s =>'GEEKSFORGEEKS'>;> > >for> (>auto>& x : s) {> >x =>tolower>(x);> >}> > >cout << s;> >return> 0;> }> |
>
analyser la chaîne en entier
>Sortir
geeksforgeeks>
Note: Si le caractère passé dans tolower() est l'un de ces trois
- caractère minuscule
- symbole spécial
- chiffre
tolower() renverra le caractère tel quel.
Exemple 3 :
C++
instanciation en Java
// C++ program to demonstrate> // example of tolower() function.> #include> using> namespace> std;> > int> main() {> > >string s=>'Geeks@123'>;> > >for>(>auto> x:s){> > >cout << (>char>)>tolower>(x);> >}> > >return> 0;> }> |
>
>Sortir
geeks@123>