-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
93 lines (91 loc) · 2.44 KB
/
main.cpp
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include <bits/stdc++.h>
#include "auto_correct.h"
#include "windows.h"
#define ll long long
COORD cord = {0, 0};
using namespace std;
auto_correct spell;
int pos=9;
void gotox (int x, int y)
{
cord.X = x; cord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), cord);
}
void setcolour(int ForgC)
{
WORD wColor;
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO csbi;
if(GetConsoleScreenBufferInfo(hStdOut, &csbi))
{
wColor = (csbi.wAttributes & 0xF0) + (ForgC & 0x0F);
SetConsoleTextAttribute(hStdOut, wColor);
}
}
int main()
{
//cout<<"Hello";
pos++;
gotox(43, ++pos);
cout<<"1. Check for errors in a file"<<endl;
pos++;
gotox(46, ++pos);
cout<<"2. Check spellings manually"<<endl;
pos++;
gotox(48, ++pos);
cout<<"3. Enter 3 to Exit"<<endl;
pos++;
gotox(40, ++pos);
setcolour(15);
while(1){
//cout<<"\nEnter the string to be CHECKED\n";
int choice=0;
cin>>choice;
if(choice == 1){
cout<<"Enter filename: ";
string filename, s="";
ifstream fin;
cin>>filename;
fin.open(filename);
if(!fin){
cout<<"File doesn't exists"<<endl;
}
else{
while(fin>>s){
cout<<endl;
if(s!=""){
spell.correct(s);
}
}
}
cout<<endl;
cout<<endl;
cout<<"1. Check for errors in a file"<<endl<<endl;
cout<<"2. Check spellings manually"<<endl<<endl;
cout<<"3. Enter 3 to Exit"<<endl<<endl;;
}
else if(choice ==2){
while(true){
string s;
cout<<"\nEnter the string to be CHECKED or exit to go back\n";
cin>>s;
if(s=="exit"){
cout<<endl;
cout<<"1. Check for errors in a file"<<endl<<endl;
cout<<"2. Check spellings manually"<<endl<<endl;
cout<<"3. Enter 3 to Exit"<<endl<<endl;;
break;
}
spell.correct(s);
cout<<endl;
}
}
else if(choice==3){
return 0;
}
else {
cout<<"You need to enter a valid choice mate!"<<endl;
}
}
return 0;
}