Pages

Tuesday, April 22, 2025

String Member Functions in C++

 #include <iostream>

#include <cstring>

using namespace std;


int main()

{

    // string str = "apna college";

    string str = "java, c++ and python & c++ with c++ magic";

    

    // cout << str.length() << endl;

    // cout << str[2] << endl;

    // cout << str.at(2) << endl;

    // cout << str.substr(5, 5) << endl;

    // cout << str.find("c++", 26) << endl;

    

    int idx = str.find("c++");

    cout << idx << endl;


    return 0;

}

No comments:

Post a Comment

Stack using Linked List – Partial (University Exam Topic)

 #include <iostream> using namespace std; struct Node {     int data;     Node* next; }; class Stack {     Node* top; public:     Stac...