Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6366363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:24:43+00:00 2026-05-25T00:24:43+00:00

Off lately I am working with Berkeley DB. I have seen examples wherein people

  • 0

Off lately I am working with Berkeley DB. I have seen examples wherein people have used “string” as values to “key.data” while creating a database using Berkeley DB. I want to assign an integer value to it. How can I do that? Should I create a structure with int member in it or is there any other way possible?

DBT key, data;
memset(&key, 0, sizeof(key));
memset(&data, 0, sizeof(data));
key.data = "fruit";
key.size = sizeof("fruit");

So instead of “fruit” above I want to assign an integer value. Any kind of help would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T00:24:43+00:00Added an answer on May 25, 2026 at 12:24 am

    DBT structures provide a void * field that you use to point to your
    data, and another field that identifies the data length. They can
    therefore be used to store anything from simple primitive data to
    complex structures so long as the information you want to store
    resides in a single contiguous block of memory.

    See, http://download.oracle.com/docs/cd/E17076_02/html/gsg/C/DBEntry.html

    To store integers, you would assign a pointer to an int to key.data, e.g.:

    int x = 42;
    key.data = &x;
    key.size = sizeof(x);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm working in a webservice built on top off symfony framework. Lately i was
I am currently working on a website and lately have been using GD with
I am developing a project that lately have been taking off with increased popularity.
First off I've been working with Java's Concurrency package quite a bit lately but
Off lately I have taken up the task to understand and learn C. Right
First off, I am using Windows XP. I have multiple hard drives and it
First off, I'm working on an app that's written such that some of your
I have done a few projects lately using a Database Object super class which
Piggy backing off another question I posted , I have a complex find() that
I've been reading Code Complete lately, based off of many references here and also

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.