Strings

PHOTO EMBED

Thu Aug 18 2022 07:22:06 GMT+0000 (Coordinated Universal Time)

Saved by @Rishi2413 #c++

#include<iostream>
using namespace std;

int main(){

//finding the length of the string

    string para = "I am Rishi";
    cout << para.length() << endl;

//finding according to the index of the string

    cout << para[2] << endl;

// replacing a string

    para[0] = 'G';
    cout << para << endl;

//substring

    cout  << para.substr(3, 4);

// creating another variable for the substring

    string parasub = para.substr(3, 4);
    cout << parasub << endl;

    return 0;
}

content_copyCOPY