Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

find substring after character

// CPP program to illustrate substr()
#include <string.h>
#include <iostream>
using namespace std;
 
int main()
{
    // Take any string
    string s = "dog:cat";
 
    // Find position of ':' using find()
    int pos = s.find(":");
 
    // Copy substring after pos
    string sub = s.substr(pos + 1);
 
    // prints the result
    cout << "String is: " << sub;
 
    return 0;
}
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #find #substring #character
ADD COMMENT
Topic
Name
1+4 =