08.01.2014, 16:04. Просмотров 1038. Ответов 3
Вот код программы. В роди бы написана правильно, но компилятор выдает "Работа программы завершена!"
C++ |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
| #include <iostream>
#include <conio.h>
using namespace std;
int myfind(char* str,char* sub_str)
{
char temp[64];
int i=0;
int k;
int count = 0;
while(str[i] != '\0')
{
memset(temp,0,64);
k = 0;
while(str[i] != ' ')
{
temp[k] = str[i];
i++;
k++;
}
if(strcmp(sub_str,temp) == 0) count++;
i++;
}
return count;
}
int main()
{
char str[] = "hello he lo lo he hello li hello";
char sub[] = "hello";
cout<<str<<endl;
cout<<myfind(str,sub);
getch();
return 0;
} |
|