Search word and text

 


//text search

#include<iostream.h>

#include<string.h>

#include<iomanip>




int main(int argc, char *argv[])

{

string s1("hello");

string s2(" world");

s1+=s2;

int n;

n=s1.find('l');

if(n!=-1)

cout<<setw(25)<<"first text position="<<n<<endl;

n=s1.rfind('l');

if(n!=-1)

cout<<setw(25)<<"last text position="<<n<<endl;

n=s1.find("llo");

if(n!=-1)

cout<<setw(25)<<"first word position="<<n;


return 0;

}

Comments

Popular posts from this blog

stepper_28BY_and_with_driver_and-pic18f4550

Inductance caculator

polluted enviroment အဆိပ္သင့္ ရပ္ဝန္း