All string operations/functions in c++

439


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

int main()
{
// APPENDING OR ADDING ANY TWO STRINGS

        //   string s1,s2;

        //   s1 = "fam" ;
        //   s2 = "ily" ;

        //   s1.append(s2); 
        //   cout << s1 ;


        //   cout << s1 + s2;
            
            
// ACCESSING THE PARTICULAR ELEMENT OF THE string

        // string s="family";
        // cout<<s[1];

// FOR CLEARING THE WHOLE STRING     //  CLEAR FUNCTION 

        // string s1="sfjaljfalfjal";
        // cout<<s1;
        
        // s1.clear();
        // cout<<s1;
        
// COMPARING THE TWO STRINGS   // COMPARE FUNCTION 

        // string s1="abc" ;
        // string s2 = "xyz" ;
          
        // if(s1.compare(s2)==0)
        // cout << " string are equal " ;
          
        // else
          
        // cout << " strings are not equal ";
          
// CHECKING WEATHER STRING IS EMPTY OR NOT //   EMPTY FUNCTION

        // string s1="abc";
        // s1.clear();
          
        // if(s1.empty())
        // cout<<"string is empty";
          
        // else
        // cout << " string is not empty " ;

// DELETING THE PARTICULAR ELEMENT FROM THE STRING // ERASE FUNCION  

        // string s = "nincompoop";
        // cout << s ;
        
        // s.erase(3,1); cout << endl ;
        // cout << s ;
        
// FINDING THE ELEMENTS IN THE STRING // FIND FUNCTION 

      // string s = "nincompoop" ;
      // cout << s.find("poo");

// INSERTING THE ELEMENTS IN BETWEEN OF THE STRING // INSERT FUNCTION

      // string s1 = "nincompoop";
      // cout << s1 << endl;
      
      // s1.insert(2,"lol");
      // cout << s1;
        
// FINDING OUT THE LENGTH OF THE STRING // SIZE AND LENGTH FUNCTION

    // string s1;
    // s1 = "nincompoop";
    // cout << s1.size();
        
// FOR PRINTING THE SUNSTRING OF THE STRING // SUNSTR() FUNCTION

    // string s1="nincompoop";
    // cout << s1.substr(3,9);
    
// CONVERTING NUMERIC STRING TO INTEGER STRING // STOI FUNCTION

    // string s1="786";
    // int x = stoi(s1);
    // cout << x+2;
     
// CONVERTING INEGER TO STRING FORM  

    // int s1=786;
    // cout << to_string(s1) + "2" ;
    
// SORTING THE STRING IN ASCENDING ORDER

  // string s1 = "kshitj" ;
  // cout << s1 << endl;
   
  // sort( s1.begin() , s1.end() );
  // cout<< s1 ;
  
// SORTING THE STRING IN DESCENDING ORDER

  // string s1 = " kshitij ";
  // cout << s1 <<endl;
  
  // sort( s1.begin(), s1.end(), greater<int>());
  // cout << s1;
  
   

return 0;

}