.TH dbm_firstkey() "" "" "NDBM Function (libgdbm)"
.PC "Retrieve the first key from an NDBM data base"
.B "#include <ndbm.h>"
\fBdatum dbm_firstkey (\fIdatabase\^\fB)\fR
\fBDBM *\fIdatabase\^\fB;\fR
.PP
Function
.B dbm_firstkey()
retrieves the record with the first key in
.IR database .
.I database
must first have been opened through a call to function
.BR dbm_open() .
.PP
.B dbm_firstkey()
returns the address of the record it has retrieved.
It returns NULL either if something went wrong (e.g., it could not read
.IR database ),
or if
.I database
is empty.
.PP
You can use
.B dbm_firstkey()
with function
.B dbm_nextkey()
to walk through
.IR database .
For example:
.DM
	for (key = dbm_firstkey(db); key.dptr != NULL; key = dbm_nextkey(db))
.DE
.SH "See Also"
.XR "dbm_nextkey()," dbm_nextk
.XR "ndbm.h," ndbm.h
.XR "libgdbm" libgdbm
.SH Notes
For a statement of copyright and permissions on this routine, see the
Lexicon entry for
.BR libgdbm .
