Creating a text editor.
Thread 1 creates a file and listens for user input.
Thread 2 checks for spelling mistakes.
How do I show spelling mistakes on the console? Should I highlight the text that has the spelling mistake? I tried that but it just highlights the following text in the console.
My code:
void TeditCommand(){
ofstream output(paths[1]);
string temp;
if(output.is_open()){
cout << "\n\nText Editor\n";
cout << paths[1] << endl;
cin >> temp;
output << temp;
output.close();
}
else{
cout << "Cannot open file" << endl;
}
}
void TeditSpellCheck(){
ifstream infile(paths[1]);
string word;
if(infile.is_open()){
while(getline(infile,word)){
if(word!=checker.correct(word))//if word not equal to a possible correct word
{
HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
if (hStdout == INVALID_HANDLE_VALUE)
{
cout << "Error while getting input handle" << endl;
}
SetConsoleTextAttribute(hStdout, FOREGROUND_BLUE| BACKGROUND_BLUE | FOREGROUND_INTENSITY);
}
}
}
}
In the main():
thread first(TeditCommand);
thread second(TeditSpellCheck);
//TeditCommand();
//TeditSpellCheck();
first.join();
second.join();
Win32 Console Application