.TH nextkey() "" "" "DBM Function (libgdbm)"
.PC "Retrieve the next record from a DBM data base"
.B "#include <dbm.h>"
\fBdatum nextkey ()\fR
.PP
Function
.B nextkey()
retrieves the next record from the currently open DBM data base.
The data base must first have been opened by a call to
.BR dbminit() ,
and the first record within the data base must have been retrieved by a
call to
.BR firstkey() .
.PP
.B nextkey()
returns a pointer to the retrieved record.
If no record is available (i.e., every record has already been retrieved),
or if an error occurred, field
.B dptr
within the returned record is initialized to NULL.
.PP
You can use this function with function
.B firstkey()
to walk through the entire contents of a DBM data base.
For example:
.DM
	for(key=firstkey(); key.dptr!=NULL; key=nextkey(key))
.DE
.PP
Please note that the hashing algorithm used the DBM functions
dictates which record is ``next'' within the data base.
A loop that uses this function plus the function
.B firstkey()
will retrieve every record from the data base; however, the records probably
will not be in the order you expect.
.SH "See Also"
.XR "dbm.h," dbm.h
.XR "firstkey()," firstkey
.XR "libgdbm" libgdbm
.SH Notes
For a statement of copyright and permissions on this routine, see the
Lexicon entry for
.BR libgdbm .
