Created
February 8, 2016 17:44
-
-
Save takuya/fc3dc57b0ecb8eb58d14 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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