tolower() Funzione in C++
Il C++ ridurre() la funzione converte un alfabeto maiuscolo in un alfabeto minuscolo. È una funzione predefinita di ctype.h file di intestazione. Se il carattere passato è un alfabeto maiuscolo, la funzione tolower() converte un alfabeto maiuscolo in un alfabeto minuscolo. Questa funzione non influisce su altri caratteri minuscoli, simboli speciali o cifre.
int tolower(int ch);
Parametro:
- ch: è il carattere da convertire in minuscolo.
Valore di ritorno: Questa funzione restituisce il valore ASCII di carattere minuscolo corrispondente al cap.
In C++, il typecasting di int in char viene eseguito come segue:
char c = (char) tolower('A'); I programmi seguenti illustrano la funzione tolower() in C++:
Esempio 1:
C++
// 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);> }> |
Produzione
G in lowercase is represented as = g
Esempio 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;> }> |
Produzione
geeksforgeeks
Nota: Se il carattere passato in tolower() è uno di questi tre
- carattere minuscolo
- simbolo speciale
- cifra
tolower() restituirà il carattere così com'è.
Esempio 3:
C++
// 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;> }> |
Produzione
geeks@123