text: gOOGLE cASE of a given sentence | C ++ program to convert a sentence to gOOGLE cASE . ; Empty strings ; Convert input string to upper case ; Check if character is not a space and adding it to string w ; Converting first character to lower case and subsequent initial letter of another word to lower case ; Driver code
code: #include <bits/stdc++.h> NEW_LINE using namespace std ; string convert ( string str ) { string w = " " , z = " " ; transform ( str . begin ( ) , str . end ( ) , str . begin ( ) , :: toupper ) ; str += " ▁ " ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { char ch = str [ i ] ; if ( ch != ' ▁ ' ) { w = w + ch ; } else { z = z + char ( tolower ( w [ 0 ] ) ) + w . substr ( 1 ) + " ▁ " ; w = " " ; } } return z ; } int main ( ) { string str = " I ▁ got ▁ intern ▁ at ▁ geeksforgeeks " ; cout << convert ( str ) << endl ; return 0 ; }