Răspuns:
#include <iostream>
#include <cstring>
using namespace std;
char text1[256], text2[256], cuv1[50], *p, tmp[256];
int contor, i, poz;
int main()
{
cin.getline(text1,256);
cin.getline(text2,256);
while (text1[i]!=' ')
{
cuv1[i]=text1[i];
++i;
}
cuv1[i]='\0';
p=strstr(text2,cuv1);
while (p)
{
++contor;
poz=p-text2;
strcpy(tmp,text2+poz+1);
strcpy(text2,tmp);
p=strstr(text2,cuv1);
}
cout << contor;
return 0;
}
Explicație: