Skip to content

Instantly share code, notes, and snippets.

@takuya
Created February 8, 2016 17:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takuya/fc3dc57b0ecb8eb58d14 to your computer and use it in GitHub Desktop.
Save takuya/fc3dc57b0ecb8eb58d14 to your computer and use it in GitHub Desktop.
#include <gdbm.h>
#include <stdio.h>
#include <string.h>
int main () {
GDBM_FILE gdbm_f;
datum key;
datum value;
gdbm_f = gdbm_open("test.dbm", 0, GDBM_READER, 0666, NULL );
if(!gdbm_f){
perror("Error");
printf("えらー");
return 1;
}
char *str = "www.yahoo.co.jp";
key.dptr = str;
key.dsize = strlen(str);
value = gdbm_fetch( gdbm_f, key );
if( value.dptr){
printf("Data Fetched\n");
printf("'%s' (%d)\n", value.dptr,value.dsize);
}else{
printf("Data Fetching faild\n");
}
gdbm_close( gdbm_f );
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment