-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSource1.cpp
More file actions
54 lines (34 loc) · 698 Bytes
/
Source1.cpp
File metadata and controls
54 lines (34 loc) · 698 Bytes
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
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <queue>
#include "sqlite3.h"
using namespace std;
int callbackExistingUsername(void* notUsed, int argc, char** argv, char** azCol)
{
if (argc == 0)
{
return -1;
}
return 1;
}
bool isUserExists(string username)
{
sqlite3* db;
int rc = sqlite3_open("trivia.db", &db);
char** err;
string a = "SELECT username FROM t_users WHERE username = " + username;
const char* line = a.c_str();
int rc = sqlite3_exec(db, line, callbackExistingUsername, NULL, err);
if (rc == -1)
{
return false;
}
return true;
}
void main()
{
cout << isUserExists() << endl;
cout << isUserExists() << endl;
}