[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Req for help
From: |
Srinivas . Yalamanchili |
Subject: |
Req for help |
Date: |
Wed, 03 Jul 2002 15:05:40 +0100 |
Hi there,
I am trying out this example and for some reason it does not produce the
desired result.
it returns an error 0. Probably it is unable to open the file.
I would be thankful if you can spare the time and effort to suggest a possible
solution.
Many thanks,
Srini
#include <errno.h>
#include <iostream.h>
#include <gdb
#include <string.h>
extern int errno; /* C runtime library */
int main(int argc, char *argv[])
{
cout << "Sample C++ program create a gdbm file ./tgdbm " << endl;
GDBM_FILE pfile = gdbm_open("tstgdbm", 512, GDBM_WRCREAT, 00664, 0);
if (!pfile)
{
cout << "main:gdbm_open " << gdbm_errno << errno << endl;
return -1;
}
datum key = {"foo", strlen("foo")+1};
datum val = {"bar", strlen("bar")+1};
cout << "key is : " << key.dptr << endl;
cout << "data is : " << val.dptr << endl;
if (gdbm_store(pfile, key, val, GDBM_INSERT) != 0)
{
cout << "main:gdbm_store " << gdbm_errno << errno << endl;
return -1;
}
gdbm_close(pfile);
cout << "Sample C++ program complete" << endl;
return 0;
}
------------------------------------------------------------- ---
Visit our Internet site at http://www.reuters.com
Any views expressed in this message are those of the individual
sender, except where the sender specifically states them to be
the views of Reuters Ltd.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Req for help,
Srinivas . Yalamanchili <=