The iaddrec function is called to add a new record to a database. It requires three arguments, the database handle, an index handle or NULL, and a list of record field values. The field values must be listed in the same order as the corresponding field names passed to the icreate_db function. The iaddrec function returns I_ERROR if an error occurs, or I_OK if the record is successfully added to the database.
The following example program adds a record to the BOOKS database. The user inputs the record field values, each of which is stored in a character array. The record itself is represented by an array of pointers to these field values. The field values must be listed in the same order as the corresponding field names passed to the icreate_db function.
Notice that NULL was passed as the second argument to iaddrec. This could optionally have been an index handle returned by the ihandle function. If an index handle is passed to the iaddrec function, then the new record becomes the current record for the associated index. If NULL is passed, then the current record for each index remains unchanged.