-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFindAndReplaceString.cpp
101 lines (101 loc) · 1.75 KB
/
FindAndReplaceString.cpp
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
//#include <iostream>
//using namespace std;
//char* FindAndReplaceString(char* str, char* toFind, char* toReplace)
//{
// bool flag;
// int findcount = 0, count = 0, strCount = 0;
// char*result = new char[80];
//
// while (str[strCount] != '\0')
// {
// strCount++;
// }
//
//
// while (toReplace[count] != '\0')
// {
// count++;
// }
//
// while (toFind[findcount] != '\0')
// {
// findcount++;
// }
// int y = 0;
// for (int j = 0; j < strCount; j++)
// {
// int a = 0;
// flag = true;
//
// if (str[j] == toFind[a] || str[j] == toFind[a] + 32)
// {
// a++;
//
// int b = j + 1;
//
// while (toFind[a] != '\0')
// {
// if (toFind[a] != str[b])
// {
// flag = false;
// }
// a++, b++;
// }
// if (flag == true)
// {
// int i = j + 1;
//
// for (int g = 0; g < count; g++, y++)
// {
// result[y] = toReplace[g];
// }
// j = findcount + j - 1;
// }
// }
// else
// {
//
// result[y++] = str[j];
//
// }
// if (j >= strCount)
// {
// break;
// }
//
// }
// result[y] = '\0';
//
// return result;
//}
//int main()
//{
// char buffer[80];
// cout << "Enter your string:\n";
// cin.getline(buffer, 80);
// int count = 0;
// while (buffer[count] != '\0')
// {
// count++;
// }
//
// char*str = new char[count + 1];
// int i;
// for (i = 0; i < count; i++)
// {
// str[i] = buffer[i];
// }
// str[i] = '\0';
//
//
// char toFind[40];
// char toReplace[40];
// cout << "Enter your word you want to change:\n ";
// cin >> toFind;
// cout << "Enter your word you want to change with:\n ";
// cin >> toReplace;
//
// char*result = FindAndReplaceString(str, toFind, toReplace);
// cout << result << endl;
// system("pause");
//}