Skip to content

Instantly share code, notes, and snippets.

@tanvir002700
Created April 16, 2016 09:00
Show Gist options
  • Save tanvir002700/6480fa6508e4c4aa1b95bc3bd38d965d to your computer and use it in GitHub Desktop.
Save tanvir002700/6480fa6508e4c4aa1b95bc3bd38d965d to your computer and use it in GitHub Desktop.
#include<iostream>
#include<string>
#include<stdlib.h>
using namespace std;
int main()
{
string str="somewhere, something incredible is waiting to be known.";
cout<<"Find some from first: "<<str.find("some")<<endl;
cout<<"Find some from last: "<<str.rfind("some")<<endl;
cout<<"substring: "<<str.substr(0,9)<<endl;
cout<<"substring: "<<str.substr(11,9)<<endl;
cout<<"lexicographically small: "<<min(str.substr(0,9),str.substr(11,9))<<endl;
cout<<"lexicographically large: "<<max(str.substr(0,9),str.substr(11,9))<<endl;
return 0;
}
Find some from first: 0
Find some from last: 11
substring: somewhere
substring: something
lexicographically small: something
lexicographically large: somewhere
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment