|
Last change
on this file since 3014 was 2036, checked in by bird, 21 years ago |
|
Initial revision
|
-
Property cvs2svn:cvs-rev
set to
1.1
-
Property svn:eol-style
set to
native
-
Property svn:executable
set to
*
-
Property svn:keywords
set to
Author Date Id Revision
|
|
File size:
454 bytes
|
| Line | |
|---|
| 1 | #include <search.h>
|
|---|
| 2 | #include <stdio.h>
|
|---|
| 3 |
|
|---|
| 4 | int
|
|---|
| 5 | main (void)
|
|---|
| 6 | {
|
|---|
| 7 | int a = 1;
|
|---|
| 8 | int b = 2;
|
|---|
| 9 | ENTRY i;
|
|---|
| 10 | ENTRY *e;
|
|---|
| 11 |
|
|---|
| 12 | if (hcreate (20) == 0)
|
|---|
| 13 | {
|
|---|
| 14 | puts ("hcreate failed");
|
|---|
| 15 | return 1;
|
|---|
| 16 | }
|
|---|
| 17 |
|
|---|
| 18 | i.key = (char *) "one";
|
|---|
| 19 | i.data = &a;
|
|---|
| 20 | if (hsearch (i, ENTER) == NULL)
|
|---|
| 21 | return 1;
|
|---|
| 22 |
|
|---|
| 23 | i.key = (char *) "one";
|
|---|
| 24 | i.data = &b;
|
|---|
| 25 | e = hsearch (i, ENTER);
|
|---|
| 26 | printf ("e.data = %d\n", *(int *) e->data);
|
|---|
| 27 | if (*(int *) e->data != 1)
|
|---|
| 28 | return 1;
|
|---|
| 29 |
|
|---|
| 30 | return 0;
|
|---|
| 31 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.