# include <iostream> # include <string> # include <fstream> using namespace std; int main () { char *a; char *b; char *c; ifstream word("word.txt"); while (!word.eof()) { word>>c; [COLOR="Red"]// line 14[/COLOR] a=c; [COLOR="blue"] //line 15[/COLOR] ifstream wordL ("wordlist.txt"); while (!wordL.eof()) { wordL >> c; [COLOR="red"]// line 19 [/COLOR] b = c; [COLOR="blue"]//line 20[/COLOR] if (strlen(a)==strlen(b)) { cout<< lenght is equal; } } } cin.get(); }
note:
line 14 and 19 have the same variable where the string from the document is moved,coz when i put different variable the program run but a pop up appear saying "illegal operation".
line 16 and line 20 are the line where i move the content of the variable(where string from the document were moved) to another variable. Suppose to be, when line 19 is executed the string from document move to variable c but this is not exactly what happend the string of the document is also moved to variable a. that's why the if block is always true.
how can i fix this?
BTW,im using dev-C++