-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.cpp
56 lines (44 loc) · 1.23 KB
/
utils.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
#include "utils.h"
#include <string>
/*----------------------------------------------------------------------------------------------*/
void gotoxy(int x, int y)
{
HANDLE hConsoleOutput;
COORD dwCursorPosition;
cout.flush();
dwCursorPosition.X = x;
dwCursorPosition.Y = y;
hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hConsoleOutput, dwCursorPosition);
}
/*----------------------------------------------------------------------------------------------*/
void hideCursor()
{
HANDLE myconsole = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO CURSOR;
CURSOR.dwSize = 1;
CURSOR.bVisible = FALSE;
SetConsoleCursorInfo(myconsole, &CURSOR);//second argument need pointer
}
/*----------------------------------------------------------------------------------------------*/
void setTextColor(Color colorToSet) {
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), (int)colorToSet);
}
/*----------------------------------------------------------------------------------------------*/
bool checkIfInt(std::string s) {
int i = 0;
if (s.length() == 0)
{
return false;
}
for (i; i < s.length(); i++) {
if (s[i] >= '0' && s[i] <= '9')
{
//noting
}
else {
return false;
}
}
return true;
}