Filestreaming--wordguard

hi again!

I have a project about filestreaming and I am a beginner in c++. Anyone who can help me improve my code.

cat
dog
fox ---
test ---filters.txt
goal

The quick
brown *** ----> the asterisk here is supposed to be fox.
jumped over ---> original.txt
the lazy
*** ------------->the asterisk here is supposed to be dog

If it identifies any of these words: cat, dog, fox, test and goal, it will appear as asterisk...But my code is not that good enough.



#include <fstream>
#include <iostream>

using namespace std;

int main()
{

char words[100][100]={'\0'};
char words2[100][100]={'\0'};

ifstream fin("filters.txt");
ifstream fin2("original.txt");

char ch;
char ch2;
int row =0;
int col=0;
while(fin.get(ch)) {
if(ch=='\n' ){
++row;
col=0;
}
words[row][col++]=ch;
if (ch2=='\n' || ch2 == ' ') {
++row;
col=0;
}
}
fin.close();
int w1Row = row;

for(int i=0;i<=row;++i) {
cout<<endl<<words[i];
}

row = 0;
col = 0;

while(fin2.get(ch2)){
if(ch2=='\n' || ch2 == ' '){
++row;
col=0;
}

words2[row][col++]=ch2;

if (ch2=='\n' || ch2 == ' ') {
++row;
col=0;
}
}
fin2.close();

cout<<strcmp(words[4], words[4]);
for(int i=0;i<=w1Row;++i) {
for (int j = 0; j <= row; ++j) {
if (strlen(words2[j]) > 1)
if (strcmp(words[i], words2[j]) == -1) {
for (int k = 0; k < strlen(words[i]); ++k)
words2[j][k] = '*';
}
//cout<<strlen(words2[i])<<endl;
}
}

for (int j = 0; j <= row; ++j)
cout<<words2[j];

cout<<endl;
system("pause");
}




Topic archived. No new replies allowed.