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

serial to parallel test with 74c595 and pic mcu

ဆိုလာ စနစ္ရွိ BATTERY AMPACITY အား design ထုတ္တြက္ခ်က္ၿခင္း (1) watt hour ရယူၿခင္း

INTERRUPT_ON_CHANGE_18f4550