Solution was to change datatype of key values from constant character pointer const char *
to char array.
char fruit[sizeof("fruit")] = "fruit";
char apple[sizeof("apple")] = "apple";
Additionally , even using string
instead of const char *
for key-values gives similar issue as mentioned in the question, somehow I could make it work only with char array.
Reference : BerkeleyDB.example
2
solved Berkeley DB C++ showing incorrect key-value string data