Skip to content

Instantly share code, notes, and snippets.

Created February 6, 2013 00:02
Show Gist options
  • Save anonymous/4718936 to your computer and use it in GitHub Desktop.
Save anonymous/4718936 to your computer and use it in GitHub Desktop.
#include <stdio.h>
void spellCheck(char article[], char dictionary[]) {
char *art = article;
int start_index;
int end_index;
int count = 0;
while (art[count] != NULL) {
start_index = count;
if ( art[count] >= 'A' && art[count] <= 'Z' ) {
art[count] = art[count] + 32;
count++;
}
else if ( art[count] >= 'a' && art[count] <= 'z' ) {
//wordchar = count2;
//wordchar++;
count++;
}
else {
end_index = count;
// Spell check against dictionary
checkDictionary( art, dictionary, start_index, end_index);
while ( !( ( art[count] >= 'A' && art[count] <= 'Z' ) || (art[count] >= 'a' && art[count] <= 'z') ) )
count++;
}
}
}
void checkDictionary( char arti[], char dict[], int start, int stop ) {
char *dic = dict;
int dcount = 0;
int dcount2 = 0;
while (dict[dcount2] != NULL) {
if ( dict[dcount2] >= 'A' && dict[dcount2] <= 'Z' ) {
dict[dcount2] = dict[dcount2] + 32;
}
if ( dict[dcount2] >= 'a' && dict[dcount2] <= 'z' ) {
//put char into array
putchar (dict[dcount2]);
dcount2++;
}
else {
dcount2++;
}
if ( dict[dcount2] == '\n' ) {
//compare array to word from article
dcount = dcount2;
printf ("\n");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment