Source Code For Name Suggestion

Hi!
I am making a program for my final year School Project. In the program, I have to add a function that accepts a person's name and searches for it in a given data file. Currently, my function checks and displays if the name is present or not! I got that part right! But, there has to be a feature thats gives suggestions of names already existing in the data if exact match is not found. It is to display the person's name if the Input is 50% right. For example, If I have a name 'Jackson' in my data and I search for 'Jack', the function should display 'Jackson' as a suggestion!!
Can anyone please help me with writing the code for this function? Pleaseee!!!
Thanks for the Help in Advance!!!
Well you can also read each name individually into a character array, then use a for loop to check if the names are the same.

Then you can put a counter for every match of character there is, beyond a certain count may be like a certain amount of characters matched, then you can put that against how many characters are in the person's name to come up with a percentage.

Something like that, I think. lawl

This is a tough project.

GOOD LUCK!
Well, thank you so much for your help! I've got the Idea, but I need help in writing the code! Its really confusing!! Let me give it another try..........
Ok, here's what I got, it checks for name matches in a file, if it finds one it breaks.

The text file has to be placed in the same folder as where your .cpp source file is. It's named "blah" and it's a .txt file. Also, has names listed in a column, in other words: Type in one name, hit enter, type in another etc. So that the names are listed top to bottom, in the text file.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <iostream>
#include <fstream>
using namespace std;

int main() {
	char filename[30];
	char enteredname[30];
	int numberofnames = 0;
	int loopcounter = 0;
	bool checkcondition = 0;
	ifstream readfile;
	readfile.open("blah.txt");

	cout << "Please enter number of names to be checked against in the file." << endl;
	cin >> numberofnames;
	cout << "Please enter name to be checked against." << endl;
	cin >> enteredname;

	while (loopcounter < numberofnames) {
		readfile >> filename;
		int namecounter = 0;
		
		while ((filename[namecounter] != '\0') || (enteredname[namecounter] != '\0')) {
			if (filename[namecounter] != enteredname[namecounter]) {
				cout << "No match." << endl;
				checkcondition = false;
				break;}
			checkcondition = true;
			namecounter++;}

		if (checkcondition) {cout << "Match has been found: " << filename << endl; break;}
		
		loopcounter++;}


	while (true) {}

	
	return 0;}
You may find this useful http://en.wikipedia.org/wiki/Levenshtein_distance

@creekist: Keep the console open http://www.cplusplus.com/forum/articles/7312/
and don't post "full solutions" http://www.cplusplus.com/articles/DjGEy60M/
got it got it, I was gonna work on a percentage solution for the name thing, lulz
@creekist: Thanks!!! Helped me a lot! Got an Idea now......... Really Great help! Got me going.......
@ne555: Thanks for the link!!
Topic archived. No new replies allowed.