-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_sqlite.cpp
More file actions
54 lines (46 loc) · 1.27 KB
/
Copy pathtest_sqlite.cpp
File metadata and controls
54 lines (46 loc) · 1.27 KB
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
/***************************************************
* Read my telbook from sqlite database
* CopyRight: Ghostwwl
* Email : gostwwl@gmail.com
***************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <sqlite3.h>
#include <string.h>
int main(int argc, char* argv[])
{
sqlite3 *db;
char *szErrMsg = 0;
int rc, irow = 0, icolumn = 0;
int i, j;
char ** szResult;
char strSQL[1024]="";
int a=0;
char dbfile[128];
printf ("Please Input The SqliteDB Full Name:");
if (fgets (dbfile, sizeof(dbfile), stdin) == NULL)
{
exit(0);
}
rc = sqlite3_open(dbfile, &db);
if( rc )
{
fprintf(stderr, "Can't open database: %sn", sqlite3_errmsg(db));
sqlite3_close(db);
exit(1);
}
rc = sqlite3_exec(db, "BEGIN;", 0, 0, &szErrMsg);
sqlite3_get_table(db, "SELECT * FROM thread limit 1000;", &szResult, &irow,
&icolumn, &szErrMsg);
printf("\nname mobile\n");
printf("-------------------------------\n");
for( i = 1; i <= irow; i++)
{
printf(szResult[i*icolumn]);
}
sqlite3_free_table(szResult);
rc = sqlite3_exec(db, "COMMIT;", 0, 0, &szErrMsg);
sqlite3_close(db);
system("pause");
return 0;
}