i want to write a program that read file2.txt and compare each words in file2.txt with noindex.txt. If there are any words which is in file2.txt but not in noindex.txt, i am suppose to put it in a linked list, then later save the linked list in index.txt.

the problem now is: why the program went to an infinite loop ?

actually i am not so sure wether my implementation or way is correct. Please correct and comment on my code. Thanks in advance.

each word in file2.txt need to be compare to the noindex.txt. If the word in file2.txt doesn't exists in noindex.txt, then that particular word will be inserts into the linked list and later will be saved into index.txt

>> i just need to save the word only excluding the all the puncuation marks.
Never done it before so, I would probably check the last character of the string and discard it if I don't want to include it.

Code:

#include <cctype>
int ispunct( int ch );
The ispunct() function returns non-zero if its argument is a
printing character but neither alphanumeric nor a space.
Otherwise, zero is returned.

>> 1 more thing, if i want to include the line number and the word position in that particular line, how am i suppose to do it ?
For the line number I would probably have a counter that's incremented after every '\n' occurence.
For the word position, I would have another counter that resets after every '\n' and increments one for each word.

>> what does .clear() do ?
In your case, you have to access the whole dictionary file repeatedly. When it reaches the end of file, one of the stream (fin_noindex) states, eofbit, is set to 1. When it happens, the stream is closed for further input until it's set to 0 using clear() method. And that's what you want to do beacuse you want to re-read the dictionary file over and over.