i would like to ask how to compare a string that similiar to a word from the file. As i know compare string exactly can be done by (if str1==str2) but how if it comes with a to find a similiar word. i searched all over net but i manage to get a very complicated answer as i am jst a beginner for this field. Hoping for some advice to work on it.
I have not really understood what you want to know, but perhaps you are searching for "regular expressions" [1]. Using reg ex, you can math parts of a word, and you do not necessarily know the whole word.
what i try to mean by similiar word is when we take "default" as an example. if the input is "edfault" or "faultde" that in differ character order, how can i write code to make my program to correct the spelling mistake. when i compare the program just says its not equal. and its getting worst for me when comes to suggest the correct word in program. what the thing actualy i have to know to solve this problem.?
Hmm, I do not think this can be easily done. This i what I think.
First you need to find out if the word is wrong. Therefor you are in need of a dictionary, and you have to check, if the word is in this dictionary. If yes, everything is ok.
If not, I think, you need some kind of measure for the word to predict what the right would be. From here on, I have no idea...
when comes with only two string maybe it is possible. how if my program have to scan thousand of words to find the match, moreover words from a file. doesn't that will involve arrays somemore and getting complicated?
You need to make a dictionary container to look up words; read your dictionary file into a set, for example. Then for each word, you check to see if it is in your dictionary. If a word is not in your dictionary, then you generate all possible misspellings and check for them in the dictionary until you find one. For added awesomeness, you could also ignore case.
The only tricky part would be generating the misspellings. According to another recent post on here, misspellings were defined as having 2 letters swapped. If that works for you, then a word such as "DOG" would only have 2 possible mispellings "ODG" or "DGO". Try it out on paper first with a few simple words and you'll see what's going on.
i quite not understand about 'read your dictionary file into a set'.. may i get some explaination on this... somemore, is it i have to prepare also the missspellings for each words?