title: Accessing values inside a structure in Berkeley DB using C
body: <p>I want to have a integer value to my "key.data" in Berkeley DB. Since we use DBT structures in Berkley DB,and it has "A pointer to a byte string", I created a structure for key with a memeber int. But now I am facing problem in accessing the value stored inside structure. Below is my code:</p>
  
  <pre><code>                             struct pearson_key{
                                    int k;
                             };
                               struct pearson_key keyStruct; 
                               DBT key
                               memset(&amp;key, 0, sizeof(key));
                               memset(&amp;keyStruct, 0, sizeof(struct pearson_key));
                               int k = 1;
                               keyStruct.k = k;
                               key.data = &amp;keyStruct;
                               printf("value = %s",(char*)keyStruct);
                               key.size = sizeof(keyStruct);
  </code></pre>
  
  <p>It is printing blank value.  I am new to C and structures. I know I am somewhere wrong with structures, but don't know how to rectify it. Thanks in advance.</p>