怎么获取字符串在一片字符串区域中的个数

如何获取字符串在一片字符串区域中的个数
UINT GetStrCount(LPCTSTR lpBuffer,LPCTSTR lpStr)
这么一个函数
请教下怎么实现

lpbuffer指向一块字符串缓冲区
lpstr指向特定的字符串 比如 abc
我想获取这块字符串区域中abc的个数
GetStrCount(lpbuffer,_T("abc"));

谢谢~~

------解决方案--------------------
不断strstr直到结束。
------解决方案--------------------
也可以CString::Find,不停的查找
------解决方案--------------------
C/C++ code
//================================================================= 
#include <iostream.h> 
#include "StdAfx.h"

UINT GetStrCount(LPCTSTR lpBuffer,LPCTSTR lpStr);

void main() 
{
    CString str = "asdfg--abc--oj--abc---abc+======abc" ;
    cout<<GetStrCount(str.GetBuffer(0) , "abc")<<endl;
}

UINT GetStrCount(LPCTSTR lpBuffer,LPCTSTR lpStr)
{
    CString buf =  lpBuffer ;
    int len_buf = buf.GetLength();

    CString str =  lpStr ;
    int len_str = str.GetLength();
    
    buf.Replace(lpStr,"");
    int new_len = buf.GetLength();

    int number = (len_buf-new_len)/len_str ;
    return number ;
}

------解决方案--------------------
查找啊 用Find()函数,定义个flag标志位。找到一个就flag++,flag最终的值就是字符串里有几个“abc”
------解决方案--------------------
这么多分哇,我是来接分的~嘿嘿!
------解决方案--------------------
都来抢分了啊,看来我只能找楼主DOTA了,悲剧啊,悲剧
------解决方案--------------------
用Find就可以了
好多分啊。,。。能不能接点啊
------解决方案--------------------
char Buffer[]="abcd.abcdbcd.abcd.abcd.abcd";//5
UINT GetStrCount(LPCTSTR lpBuffer,LPCTSTR lpStr)
{
UINT all=0;
char *pfound=(char*)lpBuffer;
while(pfound=strstr(pfound,lpStr))
{
all++;
pfound += strlen(lpStr);
}
return all;
}
//调用:
UINT all=GetStrCount(Buffer,"abc");

------解决方案--------------------
_countof(szBuffer);
------解决方案--------------------
CString str = "1234abc4334abc8888333abc5";

int count = 0;
int index = -1;
while ((index = str.Find("abc")) != -1)
{
count++;
str.Delete(index, 3);
}

CString strTemp;
strTemp.Format("%d", count);
MessageBox(strTemp);