SQLite3的C编程
/*=================================
.* The Standard include file.
.*
.*===============================*/
#include <stdio.h>
#include <stdlib.h>
/*=================================
.*
.* The extend include file.
.*
.*===============================*/
#include "sqlite3.h"
/* #include "sqlite3ext.h" */
int main()
{
/* Connect SQLite system. */
sqlite3 *pDatabase = NULL;
int result;
char sql[500];
char *err_msg = NULL;
int i;
result = sqlite3_open("test.db3", &pDatabase);
if( result != SQLITE_OK ) {
printf("Failure to open the database.\n");
return -1;
} else
printf("Good to open the database.\n");
sprintf(sql,"BEGIN");
sqlite3_exec(pDatabase, sql,0,0,err_msg);
sprintf(sql, "CREATE TABLE [TestDB] (\
[id] int, [name] varchar(20), [age] int)");
/*
if (SQLITE_OK != sqlite3_exec(pDatabase, sql, 0, 0, &err_msg)) {
printf("operate failed: %s.\n", err_msg);
return -1;
}*/
for(i = 0; i < 10000; i++) {
sprintf(sql, "INSERT INTO [TestDB] ([id], [name], [age]) \
相关文档:
再说在linux下建立.a 和点so
到网站下载 sqlite-amalgamation-3.6.22.tar.gz 这个包,反正我下了sqlite3-3.6.22.bin.gz解压后编译不了。
解压,运行
# ./configure --host=armv5l-linux --prefix=/opt/sqlite3/arm --enable-threadsafe.
......
C语言的回调函数思想代码:
#include <stdio.h>
void *max(void *base, unsigned int nmemb, unsigned int size,
int (*compar)(const void *, const void *))
{
int i;
void* max_data = base;
char* tmp = base;
&nbs ......
< type="text/javascript">
原文请见这里
。
GNU
C的一大特色(却不被初学者所知)就是__attribute__机制。__attribute__可以设置函数属性(Function
Attribute)、变量属性(Variable Attribute)和类型属性(Type Attribute)。
__attribute__书写特征是:__attribute__前后都有两个下划 ......
/*
* Exercise 2-5 Page 48
*
* Write the function any(s1,s2), which returns the first location
* in the string s1 where any character from the string s2 occurs,
* or -1 if s1 contains no characters from s2. (The standard library
* function strpbrk does the same job but returns a pointer t ......
如果要加入此计划:
1、
方式1
:加入
QQ
群:
93684322
。
2、
方式2
:加入
CSDN
群组:
DS计划
。
1.1 变量存储域
1.1.1 一个示例
pang123hui首先提供了一个网上流传的学习代码示例:
int a = 0; //全局区
void main()
{
int b; //栈
char s[] = “abc” ......