[comp.unix.xenix] hsearch

root@ozdaltx.UUCP (root) (06/28/90)

I seem to be having a problem with SCO's function, hsearch().
286 version.

In playing with the code they use as an example; (manual dated 6/21/87)
It keeps referencing to check the source code - I don't seem to have
the source code available... any one know if this is a typo?  OR are
they talking about search.h?

Also, I seem to have a problem with printing longs when read from the
table.  I read in a file (in this case, my news/active file) using

fscanf("%s%ld%ld", str_ptr,&info_ptr->low.....)

and later try to print out the table.  Placing a printf right after
the fscanf does show the correct numbers.   But, I get HUGE numbers
if a digit goes over 255 (I think) when I access the table for
information.  This is right out of the manual, with the exception of
some additional defs in the info structure; using the code in the example:

(later in the supplied code):
    printf(%s  %ld  %ld", found_item->key,
       ((struct info *)found_item->data)->low... etc)

The data table is set as:
struct info {
      char *name;
      long low;
      long high;
      .... some other defs;
};

I've tried changing the longs to char *, but the thing does core
dumps all over the place, (after making the approperiate changes in
print/scanf).  This seems to be the only "supplied" routine to allow
a data table ... unless I'm not understanding the descriptions of 
[tlb]search().

Any help, comments, suggestions?  I'm not a heavy programmer, so for
me to try and write tables/btrees, etc would almost be more than I
want to fool with.

Oh yeah, anyone know if atol() is broken? It don't give the right
number, but sscan does.
Thanks...
Scotty
-------
AIDS INFORMATION EXCHANGE BBS      (214) 247-2367/247-5609
               "Education is the best weapon"
{mic,void,egsner}!ozdaltx!sysop || {uunet,smu,ames}!sulaco!ozdaltx!sysop