⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tchdbex.c

📁 高性能嵌入式数据库在高并发的环境下使用最好是64位系统比较好
💻 C
字号:
#include <tcutil.h>#include <tchdb.h>#include <stdlib.h>#include <stdbool.h>#include <stdint.h>int main(int argc, char **argv){  TCHDB *hdb;  int ecode;  char *key, *value;  /* create the object */  hdb = tchdbnew();  /* open the database */  if(!tchdbopen(hdb, "casket.hdb", HDBOWRITER | HDBOCREAT)){    ecode = tchdbecode(hdb);    fprintf(stderr, "open error: %s\n", tchdberrmsg(ecode));  }  /* store records */  if(!tchdbput2(hdb, "foo", "hop") ||     !tchdbput2(hdb, "bar", "step") ||     !tchdbput2(hdb, "baz", "jump")){    ecode = tchdbecode(hdb);    fprintf(stderr, "put error: %s\n", tchdberrmsg(ecode));  }  /* retrieve records */  value = tchdbget2(hdb, "foo");  if(value){    printf("%s\n", value);    free(value);  } else {    ecode = tchdbecode(hdb);    fprintf(stderr, "get error: %s\n", tchdberrmsg(ecode));  }  /* traverse records */  tchdbiterinit(hdb);  while((key = tchdbiternext2(hdb)) != NULL){    value = tchdbget2(hdb, key);    if(value){      printf("%s:%s\n", key, value);      free(value);    }    free(key);  }  /* close the database */  if(!tchdbclose(hdb)){    ecode = tchdbecode(hdb);    fprintf(stderr, "close error: %s\n", tchdberrmsg(ecode));  }  /* delete the object */  tchdbdel(hdb);  return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -