0

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

4
Contributors
5
Replies
6
Views
6 Years
Discussion Span
Last Post by jordankaushik
0

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 by Taywin: n/a

0

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.

0

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???

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.