|
-
October 10th, 2005, 11:15 PM
#1
Find the number of entries of a particular string
Can anyone show me an example in which the user has to find the number of times a string is displayed in a bigger string irrespective of spaces?
-
October 10th, 2005, 11:54 PM
#2
Re: Find the number of entries of a particular string
You have to find ur substring with basic_string::find function from begining to end, if u found ur substring then find again from next position(returned by find function) and so on untill end.
Hope this helps u.
A Person who is polite is given goodness and a person who is away from Politeness is away from Goodness.
NAUMAAN
-
October 11th, 2005, 12:10 AM
#3
Re: Find the number of entries of a particular string
 Originally Posted by maverick786us
Can anyone show me an example in which the user has to find the number of times a string is displayed in a bigger string irrespective of spaces?
you can do like this this is a Simple Program and on your Button Click it will find the given substring in a string .First start from 0 if string Found Count the Position increment it and then find the string in next string
e.g in Two edit Box Enter One Main string in First and in Second enter string to be found and on your Button Click write the function to search the substring in the string.and in your main sub string if string found set the focus on the string.here iNext3 is the member variable of your class.
Code:
CString str1;
CString str1;
BSTR bstrMess=NULL;
m_Edit11.GetWindowText(&bstrMess);;
str1 = ::SysAllocString(bstrMess);
int iText =str1.GetLength();
CString ptr1 = str1.Right(iText-iNext3);
int n= ptr1.Find(strText,0);
int j=strlen(strText);
m_Edit11.SetSel(iNext2+n,iNext3+n+j);
iNext3 += n+j;
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|