My code is very simple, just create a empty table. This is my code:
#include <stdio.h>
#include <stdlib.h>
#include <sqlite3.h>
int main(int argc, char *argv[])
{
sqlite3 *ppdb;
int retval;
retval = sqlite3_open_v2("v2.db", &ppdb,
SQLITE_OPEN_CREATE, "unix-none");
if (retval != SQLITE_OK)
{
printf(stderr, "%s\n", sqlite3_errmsg(ppdb));
return 1;
}
retval = sqlite3_exec(ppdb,
"CREATE TABLE IF NOT EXISTS userinfo \
(id TEXT PRIMARY KEY, pass TEXT NOT NULL)",
NULL, NULL, NULL);
if (retval != SQLITE_OK)
{
fprintf(stderr, "%s\n", sqlite3_errmsg(ppdb));
return 1;
}
sqlite3_close(ppdb);
return 0;
}
But when I run it, I got this error message:
Out of memory
I debug this code, I found sqlite3_open_v2 has returned 21(Library used incorrectly)
How to solve it?