📄 0952-0954.html
字号:
<HTML>
<HEAD>
<TITLE>Linux Complete Command Reference:Library Functions:EarthWeb Inc.-</TITLE>
</HEAD>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>
-->
<!-- ISBN=0672311046 //-->
<!-- TITLE=Linux Complete Command Reference//-->
<!-- AUTHOR=Red Hat//-->
<!-- PUBLISHER=Macmillan Computer Publishing//-->
<!-- IMPRINT=Sams//-->
<!-- CHAPTER=03 //-->
<!-- PAGES=0891-1062 //-->
<!-- UNASSIGNED1 //-->
<!-- UNASSIGNED2 //-->
<P><CENTER>
<a href="0950-0951.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0000-0000.html">Next</A></CENTER></P>
<A NAME="PAGENUM-952"><P>Page 952</P></A>
<P><B>RETURN VALUE
</P></B>
<P>hcreate() returns NULL if the hash table cannot be successfully installed.</P>
<P>hsearch()returns NULL if action is ENTER and there is insufficient memory to expand the hash table, or if
action is FIND and item cannot be found in the hash table.</P>
<P><B>CONFORMS TO
</P></B>
<P>SVID, except that in SysV, the hash table cannot grow.</P>
<P><B>BUGS
</P></B>
<P>The implementation can manage only one hash table at a time. Individual hash table entries can be added, but not deleted.</P>
<P><B>
EXAMPLE
</P></B>
<P>The following program inserts 24 items into a hash table and then prints some of them:</P>
<!-- CODE //-->
<PRE>
#include <stdio.h>
#include <search.h>
char *data[]={ "alpha", "bravo", "charley", "delta",
"echo", "foxtrot", "golf", "hotel", "india", "juliette",
"kilo", "lima", "mike", "november", "oscar", "papa",
"quebec", "romeo", "sierra", "tango", "uniform",
"victor", "whiskey", "x-ray", "yankee", "zulu"
};
int main()
{
ENTRY e, *ep;
int i;
/* start with small table, and let it grow */
hcreate(3);
for (i = 0; i < 24; i++)
{
e.key = data[i];
/* data is just an integer, instead of a pointer
to something */
e.data = (char *)i;
ep = hsearch(e, ENTER);
/* there should be no failures */
if(ep == NULL) {fprintf(stderr, "entry failed\n"); exit(1);}
}
for (i = 22; i < 26; i++)
/* print two entries from the table, and show that
two are not in the table */
{
e.key = data[i];
ep = hsearch(e, FIND);
printf("%9.9s -> %9.9s:%d\n", e.key, ep?ep->key:"NULL",
ep?(int)(ep->data):0);
}
return 0;
}
</PRE>
<!-- END CODE //-->
<P></B>SEE ALSO
</P></B>
<P>bsearch(3), lsearch(3), tsearch(3), malloc(3)</P>
<P>GNU, 30 September 1995</P>
<A NAME="PAGENUM-953"><P>Page 953</P></A>
<H3><A NAME="ch03_ 98">
hypot
</A></H3>
<P>hypot—Euclidean distance function</P>
<P><B>SYNOPSIS
</P></B>
<!-- CODE SNIP //-->
<PRE>
#include <math.h>
double hypot(double x, double y);
</PRE>
<!-- END CODE SNIP //-->
<P><B>DESCRIPTION
</P></B>
<P>The hypot() function returns the sqrt(x*x+y*y). This is the length of the hypotenuse of a right-angle triangle with sides
of length x and y, or the distance of the point (x, y) from the origin.</P>
<P><B>CONFORMS TO
</P></B>
<P>SVID 3, BSD 4.3</P>
<P></B>SEE ALSO
</P></B>
<P>sqrt(3)</P>
<P>25 June 1993</P>
<H3><A NAME="ch03_ 99">
index, rindex
</A></H3>
<P>index, rindex—Locate character in string</P>
<P><B>SYNOPSIS
</P></B>
<!-- CODE SNIP //-->
<PRE>
#include <string.h>
char *index(const char *s,int c);
char *rindex(const char *s,int c);
</PRE>
<!-- END CODE SNIP //-->
<P><B>DESCRIPTION
</P></B>
<P>The index() function returns a pointer to the first occurrence of the character
c in the string s.</P>
<P>The rindex() function returns a pointer to the last occurrence of the character
c in the string s.</P>
<P>The terminating NULL character is considered to be a part of the strings.</P>
<P><B>RETURN VALUE
</P></B>
<P>The index() and rindex() functions return a pointer to the matched character, or
NULL if the character is not found.</P>
<P><B>CONFORMS TO
</P></B>
<P>BSD 4.3</P>
<P></B>SEE ALSO
</P></B>
<P>memchr(3), strchr(3), strpbrk(3), strrchr(3),
strsep(3), strspn(3), strstr(3), strtok(3)</P>
<P>GNU, 12 April 1993
<H3><A NAME="ch03_ 100">
inet_aton, inet_addr, inet_network, inet_ntoa,
inet_makeaddr, <BR>inet_lnaof, inet_netof
</A></H3>
<P>inet_aton, inet_addr, inet_network, inet_ntoa,
inet_makeaddr, inet_lnaof, inet_netof—Internet
address_manipulation routines</P>
<A NAME="PAGENUM-954"><P>Page 954</P></A>
<P><B>SYNOPSIS
</P></B>
<!-- CODE //-->
<PRE>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
int inet_aton(const char *cp, struct in_addr *inp);
unsigned long int inet_addr(const char *cp);
unsigned long int inet_network(const char *cp);
char *inet_ntoa(struct in_addr in);
struct in_addr inet_makeaddr(int net, int host);
unsigned long int inet_lnaof(struct in_addr in);
unsigned long int inet_netof(struct in_addr in);
</PRE>
<!-- END CODE //-->
<P><B>DESCRIPTION
</P></B>
<P>inet_aton() converts the Internet host address
cp from the standard numbers-and-dots notation into binary data and stores
it in the structure that inp points to. inet_aton returns nonzero if the address is valid, and
0 if it is not.</P>
<P>The inet_addr()function converts the Internet host address
cp from numbers-and-dots notation into binary data in
network byte order. If the input is invalid, _1 is returned. This is an obsolete interface to
inet_aton; it is obsolete because -1 is a valid address (255.255.255.255), and
inet_aton provides a cleaner way to indicate error return.</P>
<P>The inet_network() function extracts the network number in network byte order from the address
cp in numbers-and-dots notation. If the input is invalid,
_1 is returned.</P>
<P>The inet_ntoa() function converts the Internet host address given in network byte order to a string in standard
numbers-and-dots notation. The string is returned in a statically allocated buffer, which subsequent calls will overwrite.</P>
<P>The inet_makeaddr() function makes an Internet host address in network byte order by combining the network number
net with the local address host in network net, both in local host byte order.</P>
<P>The inet_lnaof() function returns the local host address part of the Internet address
in. The local host address is returned in local host byte order.</P>
<P>The inet_netof()function returns the network number part of the Internet address
in. The network number is returned in local host byte order.</P>
<P>The structure in_addr as used in inet_ntoa(),
inet_makeaddr(), inet_lnoaf(), and inet_netof() is defined in
netinet/in.h as</P>
<!-- CODE SNIP //-->
<PRE>
struct in_addr {
unsigned long int s_addr;
}
</PRE>
<!-- END CODE SNIP //-->
<P>Note that on the i80x86 the host byte order is Least Significant Byte first, whereas the network byte order, as used on
the Internet, is Most Significant Byte first.</P>
<P><B>CONFORMS TO
</P></B>
<P>BSD 4.3</P>
<P></B>SEE ALSO
</P></B>
<P>gethostbyname(3), getnetent(3), hosts(5),
networks(5)</P>
<P>BSD, 3 September 1995</P>
<H3><A NAME="ch03_ 101">
infnan
</A></H3>
<P>infnan—Deals with infinite or not-a-number (NaN) result</P>
<P><B>SYNOPSIS
</P></B>
<!-- CODE SNIP //-->
<PRE>
#include <math.h>
double infnan(int error);
</PRE>
<!-- END CODE SNIP //-->
<P><CENTER>
<a href="0950-0951.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0000-0000.html">Next</A></CENTER></P>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -