tolower() funkcija C++ valodā

C++ pazemināt() funkcija pārvērš lielos alfabētus par mazajiem burtiem. Tā ir iepriekš noteikta funkcija ctype.h galvenes fails. Ja nodotā ​​rakstzīme ir lielo burtu alfabēts, tad funkcija tolower() pārvērš lielos alfabētus par mazajiem burtiem. Šī funkcija neietekmē citus mazos burtus, īpašos simbolus vai ciparus.

int tolower(int ch); 

Parametrs:

    ch: tā ir rakstzīme, kas jāpārvērš par mazajiem burtiem.

Atgriešanas vērtība: Šī funkcija atgriež ASCII vērtību mazie burti kas atbilst ch.

Programmā C++ int pārsūtīšana uz char tiek veikta šādi:

char c = (char) tolower('A'); 

Zemāk esošās programmas ilustrē tolower () funkciju C++:

1. piemērs:

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);> }>

Izvade

G in lowercase is represented as = g 

2. piemērs:

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;> }>

Izvade

geeksforgeeks 

Piezīme: Ja tolower() nodotā ​​rakstzīme ir kāda no šīm trim

  1. mazie burti
  2. īpašs simbols
  3. cipars

tolower() atgriezīs rakstzīmi tādu, kāda tā ir.

3. piemērs:

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;> }>

Izvade

geeks@123