hey....
I'm new to c++..
i have done a program to fine the permutations of a given string....( both with and without meaning)..
now i want to compare each permuted string with the dictionary and display the words which gives meaning...now i want to compare the permuted string with a string in a file... how can i do that???

please help me......


thanks

If you have a set of permutations, you could iterate through each of the word and use the word to search in your dictionary. (Use whatever search algorithm you want here, but I would suggest a binary search would be the best because it is sorted -- dictionary.) If you found it, the word has meaning; otherwise, ignore it. Once you are done all and got a set of meaningful words, iterate through them again. This time, you may need to use a different search algorithm or change binary search algorithm a bit to search for the word inside the file string. I think you could simply use find() function if you use a library, or you can implement the function yourself. The algorithm is not difficult, but how you implement may be a bit more tedious.

Edited 6 Years Ago by Taywin: n/a

Do you know how to use ifstream to read text files? If you do, then just read each line of the file and compare the line with the permuted string. It's a simple while loop.

Somehow i found a way to read strings in a file.... but i'm unable to go to the next line..... such that the string in the first line is checked for the given string.......if not it has to automatically go to the next line......for example::

my string is black

and the strings in the file are
blue
black.........

i always get "the strings are not equal.".... how do i make the control to go to hte next line automatically???

ya....... i got it.. and i finished the program..... thanks for all of you.......

This article has been dead for over six months. Start a new discussion instead.