-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmain.cpp
More file actions
130 lines (109 loc) · 3.11 KB
/
main.cpp
File metadata and controls
130 lines (109 loc) · 3.11 KB
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#include <iostream>
#include <fstream>
#include <sstream>
#include <iterator>
#include <vector>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <cstring>
using namespace std;
void removeAll(char * str, char * toRemove);
void replaceWithSpace(char * str)
{
int strLen = strlen(str);
for(int i = 0; i < strLen; i++)
{
if(str[i] == '<')
{
str[i] = ' ';
}
}
}
int main() {
std::ifstream t;
char str1[10][20];
int length, i, j = 0, k = 0;
t.open("element.txt");
t.seekg(0, std::ios::end);
length = t.tellg();
t.seekg(0, std::ios::beg);
char str[length];
t.read(str, length);
t.close();
char word[] = {R"(<div class="typable mono_standard play_mode" style="opacity: 1; margin-top: 0px; font-family: "Droid Sans Mono";">)"};
removeAll(str, word);
strcpy(word, R"(<div><span class="cursor normal_cursor" style="width: 21px; height: 46px; margin-top: -2px; margin-left: 0px;"></span></div>)");
removeAll(str, word);
strcpy(word, "<span class=\"line\">");
removeAll(str, word);
strcpy(word, "<span class=\"token _fcs\">");
removeAll(str, word);
strcpy(word, "<span class=\"_toknmeta\">");
removeAll(str, word);
strcpy(word, "</span><span class=\"token_unit _clr\">");
removeAll(str, word);
strcpy(word, " <i> </i></span></span>");
removeAll(str, word);
strcpy(word, "span class=\"token\">");
removeAll(str, word);
strcpy(word, "</span>");
removeAll(str, word);
strcpy(word, "</div>");
removeAll(str, word);
strcpy(word, "@");
removeAll(str, word);
strcpy(word, R"( div class="typable mono_standard play_mode" style="opacity: 1; font-family: "Droid Sans Mono"; margin-top: 0px;">)");
removeAll(str, word);
strcpy(word, "amp;");
removeAll(str, word);
replaceWithSpace(str);
cout << str;
ofstream p;
p.open("element.txt");
p << str;
p.close();
t.open("element.txt");
t.seekg(0, std::ios::end);
length = t.tellg();
t.seekg(0, std::ios::beg);
t.read(str, length);
t.close();
return 0;
}
void removeAll(char * str, char * toRemove)
{
int i, j, stringLen, toRemoveLen;
int found;
stringLen = strlen(str); // Length of string
toRemoveLen = strlen(toRemove); // Length of word to remove
for(i=0; i <= stringLen - toRemoveLen; i++)
{
/* Match word with string */
found = 1;
for(j=0; j<toRemoveLen; j++)
{
if(str[i + j] != toRemove[j])
{
found = 0;
break;
}
}
/* If it is not a word */
/*
* If word is found then shift all characters to left
* and decrement the string length
*/
if(found == 1)
{
for(j=i; j<=stringLen - toRemoveLen; j++)
{
str[j] = str[j + toRemoveLen];
}
stringLen = stringLen - toRemoveLen;
// We will match next occurrence of word from current index.
i--;
}
}
}