I need someone to debug the lines of c++ code I wrote below so it can run. It is intended to spell check the word "and" using state to state transition.
#include<iostream>
#include<string>
using namespace std;
string in_str;
int n;
void spell_check()
{
int i;
FILE *in_file;
while (!EOF(in_file))
{
fscanf(in_str);
n = strlen(in_str);
start(in_str,n);
}
}
void start()
{
char next_char;
int i = 0;
if (n == 0)
{
cout<<"This is an empty string";
exit();//do something here to terminate the program
}
else{
next_char = in_str[i];
if(next_char == 'a')
{
i++;
if(i >= n) error();
else state_A(i);
}
else error();
}
}
void state_A(int i)
{
if(in_str[i] == 'n')
{
i++;
if(i<n) state_AN(i);
else error();
}
else error();
}
void state_AN(int i)
{
if(in_str[i] == 'd')
{
if(i == n-1)
cout<<" Your keyword spelling is correct";
else
cout<<"Wrong keyword spelling";
}
}
int main()
{
spell_check();
return 0;
}