程序范例:
#include <stdlib.h>
#include <stdio.h>
#include \"sqlite3.h\"
int main(int argc, char* argv[])
{
sqlite3 *db;
char *zErrMsg = 0;
int rc;
rc = sqlite3_open(\"test.db\", &db);
if( rc ){
fprintf(stderr, \"Can\'t open database: %s\\n\", sqlite3_errmsg(db));
exit(0);
}else{
fprintf(stderr, \"Opened database successfully\\n\");
}
sqlite3_close(db);
getchar();
return(0);
}
c_cpp.json配置
{
\"configurations\": [
{
\"name\": \"Win32\",
\"includePath\": [
\"${workspaceFolder}/**\",
\"c:/mingw\",
\"C:\\\\mingw\\\\bin\",
\"C:\\\\mingw\\\\include\",
\"C:\\\\mingw\\\\lib\",
\"c:/sqlite3\"
],
\"defines\": [
\"_DEBUG\",
\"UNICODE\",
\"_UNICODE\"
],
\"intelliSenseMode\": \"msvc-x64\"
}
],
\"version\": 4
}
launch.json配置
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
\"version\": \"0.2.0\",
\"configurations\": [
{
\"name\": \"(gdb) Launch\",
\"type\": \"cppdbg\",
\"request\": \"launch\",
\"program\": \"${workspaceFolder}/hello.exe\",
\"args\": [],
\"stopAtEntry\": false,
\"cwd\": \"${workspaceFolder}\",
\"environment\": [],
\"externalConsole\": true,
\"MIMode\": \"gdb\",
\"miDebuggerPath\": \"C:/mingw/bin/gdb.exe\",
\"preLaunchTask\":\"build\",
\"setupCommands\": [
{
\"description\": \"Enable pretty-printing for gdb\",
\"text\": \"-enable-pretty-printing\",
\"ignoreFailures\": true
}
]
}
]
}
tasks.json配置
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
\"version\": \"2.0.0\",
\"tasks\": [
{
\"label\": \"build\",
\"type\": \"shell\",
\"command\": \"C:\\\\mingw\\\\bin\\\\gcc.exe\",
\"args\": [
\"-I\",\"c:/sqlite3/\",\"-L\",\"c:/sqlite3/\",\"-lsqlite3\",\"-g\",\"hello.c\",\"-o\",\"hello\"
],
\"group\": {
\"kind\":\"build\",
\"isDefault\": true
}
}
]
}
路径用\\或者/,否则报错。
系统path必须添加sqlite3的路径。
gcc参数放在args数组里面,不用每次手动输入。
版权声明
本文仅代表作者观点,不代表百度立场。
本文系作者授权百度百家发表,未经许可,不得转载。


