Skip to content

Instantly share code, notes, and snippets.

@nkt
Created October 2, 2013 17:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nkt/6797529 to your computer and use it in GitHub Desktop.
Save nkt/6797529 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
char in[101];
char sub[31];
cout<<"Введи строку: ";
cin.getline(in, 101);
cout<<"Введи слово: ";
cin>> sub;
int count = 0;
int len = strlen(sub);
for(char *p = in; (p = strstr(p, sub)); p+=len){
++count;
}
cout << count << "\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment