wij
2023-08-21 06:05:31 UTC
manpage of hsearch(3) says:
...
The argument action determines what hsearch() does after an unsuccess‐
ful search. This argument must either have the value ENTER, meaning
insert a copy of item (and return a pointer to the new hash table entry
as the function result), or the value FIND, meaning that NULL should be
returned. (If action is FIND, then data is ignored.)
...
When I want to insert an item into the hash table, I invokes hsearch(item,ENTER).
But I only want to insert the item when it is not in the hash table. How can I
do (Only invokes hsearch once. The manpage seems not mentioning the condition I
am looking for)?
...
The argument action determines what hsearch() does after an unsuccess‐
ful search. This argument must either have the value ENTER, meaning
insert a copy of item (and return a pointer to the new hash table entry
as the function result), or the value FIND, meaning that NULL should be
returned. (If action is FIND, then data is ignored.)
...
When I want to insert an item into the hash table, I invokes hsearch(item,ENTER).
But I only want to insert the item when it is not in the hash table. How can I
do (Only invokes hsearch once. The manpage seems not mentioning the condition I
am looking for)?