Search
 
SCRIPT & CODE EXAMPLE
 

CPP

convert uppercase to lowercase

// C++ program to convert whole string to
// uppercase or lowercase using STL.
#include<bits/stdc++.h>
using namespace std;
  
int main()
{
    // su is the string which is converted to uppercase
    string su = "Jatin Goyal";
  
    // using transform() function and ::toupper in STL
    transform(su.begin(), su.end(), su.begin(), ::toupper);
    cout << su << endl;
  
    // sl is the string which is converted to lowercase
    string sl = "Jatin Goyal";
  
    // using transform() function and ::tolower in STL
    transform(sl.begin(), sl.end(), sl.begin(), ::tolower);
    cout << sl << endl;
  
    return 0;
}
Comment

onvert it to lower case letter if it’s an upper case letter and convert it to upper case letter if it’s a lower

#include<iostream>
#include<string>
using namespace std; 

int main() 
{ 
    string str="Hello World"; 
    int i;
    
    cout<<"The String is: 
"<<str;
    cout<<endl<<endl;
    
    cout<<"String after uppercase lowercase modification: 
";
    for(i=0; i < str.length(); i++)
    {
        //if its uppercase add to its Ascii code 32 to make lowercase
        if(str[i]>='A' && str[i]<='Z')
      	cout<<char(str[i]+32);
      	
      	// else if its lowercase subtract 32 to make it upper case 
        else if(str[i]>='a' && str[i]<='z')
      	cout<<char(str[i]-32);
      	
      	// else if its a space or symbol for example just print it as is
      	else cout<<str[i];
      	
      	//the reason this works is that the distance in Ascii from uppercase to lowercase 
      	//is standard and constant
    }
    return 0;
}
Comment

How to convert lower case to upper case

$cat greekfile | tr “[a-z]” “[A-Z]”
Comment

PREVIOUS NEXT
Code Example
Cpp :: C++ insert character 
Cpp :: && c++ 
Cpp :: remove elements from vector 
Cpp :: bitmap 
Cpp :: c++ visual studio 
Cpp :: conversion of class type data into basic type data in c++ 
Cpp :: Check whether the jth object is in the subset 
Cpp :: Programming Languages codechef solution in c++ 
Cpp :: qt c++ qdockwidget remove title 
Cpp :: what is a .h file in c++ 
Cpp :: pointer to value of others file cpp 
Cpp :: c++ iterate through constant list 
Cpp :: The five most significant revisions of the C++ standard are C++98 (1998), C++03 (2003) and C++11 (2011), C++14 (2014) and C++17 (2017) 
Cpp :: use ster when declaring variables cpp 
Cpp :: person parametr cpp 
Cpp :: C++ Relational Operators 
Cpp :: turbo c++ easy programs 
Cpp :: jquery datepicker default date not working 
Cpp :: strong number in c++ 
Cpp :: overloading templates in cpp 
Cpp :: how to use mersenne_twister_engine in c++ to generate random numbers 
Cpp :: Create an algorithm to identify what is the next largest element on a stack (using stack/queue operations only) INPUT: [ 10, 3, 1, 14, 15, 5 ] OUTPUT: 10 - 14 3 - 14 1 - 14 14 - 15 15 - -1 5 - -1 
Cpp :: how to run the code 
Cpp :: product of array in cpp 
Cpp :: c++ multiple if conditions 
Cpp :: max in c++ with three elements 
Cpp :: what is stdoutread in c++ 
Cpp :: c++ string to const char* 
Cpp :: C++ if...else 
Cpp :: how to read and write to a file in qt c++ 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =