Click to See Complete Forum and Search --> : CString
August 22nd, 1999, 02:01 AM
Sir,
Lets suppose
CString temp="hellojshduahelloAIIHELLO";
Can I determine number of occurances of "hello" in the above "temp", how?.
Sajjad
R.K.M
August 22nd, 1999, 05:52 AM
CString temp="hellojshduahelloAIIHELLO";
CString junk = temp;
junk.MakeUpper();
int index = junk.Find("HELLO");
int count = 0;
while(index >= 0)
{
count++;
junk = junk.Right(junk.GetLength() - (index + 5));
index = junk.Find("HELLO");
}
//count is the number of occurrences, case insensituve
August 22nd, 1999, 06:42 AM
Thanks for your response, your solution works very fine.
Sir I have a simple problem left.
What I am using is to search a string "%%Pages:" in a file. I am using "fread()" to get the file contents and put the wole file in the "CString temp". Now
what follows after "%%Pages:" is an integer i.e "%%Pages: 6". Can we get this integer from the temp.
Sincerely
sajjad
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.