'a'was found in "This is a test".
'z'was not found in "This is a test".

利用函数计算字符串1中出现字符串2的次数

 

#include <iostream>
using std::cout;
using std::endl;
int main()
{
char *string1="asdfasdfasdf";
const char *string2="df";
int i=0;
while (strstr(string1,string2)!=NULL)
{
++i;
string1
=strstr(string1,string2);
string1
+=strlen(string2);

}

cout
<<i<<endl;
return 0;
}

 

 

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-05-26
  • 2022-12-23
  • 2021-10-29
  • 2021-12-16
  • 2021-07-12
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-27
  • 2022-12-23
  • 2022-12-23
  • 2022-02-20
  • 2021-09-02
相关资源
相似解决方案