Finding substrings in string objects - C++ Data Type

C++ examples for Data Type:string

Description

Finding substrings in string objects

Demo Code

#include <iostream>
#include <string>
using namespace std;
int main()//from ww w  . j  a  v  a 2 s.c  o m
{
   string s1 ="aeiou this is a test test another test";
   int n;
   n = s1.find("test");
   cout << "Found at " << n << endl;
   n = s1.find_first_of("is");
   cout << "First at " << n << endl;
   n = s1.find_first_not_of("aeiouAEIOU");
   cout << "First consonent at " << n << endl;
   return 0;
}

Result


Related Tutorials