Skip to content

Instantly share code, notes, and snippets.

@takuya
Created Feb 8, 2016
Embed
What would you like to do?
#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