Really lost. Can someone help?

Working on this assignment. Would really love any pointers.
I am supposed to design a basic spelling checker. It looks at a word and then, tells me what kind of error I made. TRANS = Transposition. SUB = Substitution.

My professor started us off by writing some of the code for us but I wasn't in class for it. Can anyone explain to me what's going on with the function: errorType functionInsertion( string gw, string bw)


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
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

enum errorType{INS, DEL, TRANS, SUB, CORRECT, BAD};

errorType functionInsertion( string gw, string bw)
{	int i = 0;
for (i = 0; i < gw.size(); i++)
	if (gw.at(i) != bw.at(i))
		break;

if ((i == gw.size()) || (gw.substr(i) == bw.substr(i)))
	return INS;

return BAD;
}

void display(errorType e)
{
	switch(e)
	{
	case INS: cout << "Insertion" << endl; break;
	case DEL: cout << "Deletion" << endl; break;
	case BAD: cout << "Bad" << endl;
	}}


Topic archived. No new replies allowed.