357 lines
7.8 KiB
HTML
357 lines
7.8 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of STRING</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>STRING</H1>
|
|
Section: Linux Programmer's Manual (3)<BR>Updated: 2019-03-06<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
stpcpy, strcasecmp, strcat, strchr, strcmp, strcoll, strcpy, strcspn,
|
|
strdup, strfry, strlen, strncat, strncmp, strncpy, strncasecmp, strpbrk,
|
|
strrchr, strsep, strspn, strstr, strtok, strxfrm, index, rindex
|
|
- string operations
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<B>#include <<A HREF="file:///usr/include/strings.h">strings.h</A>></B>
|
|
|
|
<DL COMPACT>
|
|
<DT id="1"><B>int strcasecmp(const char *</B><I>s1</I><B>, const char *</B><I>s2</I><B>);</B>
|
|
|
|
<DD>
|
|
Compare the strings
|
|
<I>s1</I>
|
|
|
|
and
|
|
<I>s2</I>
|
|
|
|
ignoring case.
|
|
<DT id="2"><B>int strncasecmp(const char *</B><I>s1</I><B>, const char *</B><I>s2</I><B>, size_t </B><I>n</I><B>);</B>
|
|
|
|
<DD>
|
|
Compare the first
|
|
<I>n</I>
|
|
|
|
bytes of the strings
|
|
<I>s1</I>
|
|
|
|
and
|
|
<I>s2</I>
|
|
|
|
ignoring case.
|
|
<DT id="3"><B>char *index(const char *</B><I>s</I><B>, int </B><I>c</I><B>);</B>
|
|
|
|
<DD>
|
|
Return a pointer to the first occurrence of the character
|
|
<I>c</I>
|
|
|
|
in the string
|
|
<I>s</I>.
|
|
|
|
<DT id="4"><B>char *rindex(const char *</B><I>s</I><B>, int </B><I>c</I><B>);</B>
|
|
|
|
<DD>
|
|
Return a pointer to the last occurrence of the character
|
|
<I>c</I>
|
|
|
|
in the string
|
|
<I>s</I>.
|
|
|
|
<DT id="5"><B>#include <<A HREF="file:///usr/include/string.h">string.h</A>></B>
|
|
|
|
<DD>
|
|
<DT id="6"><B>char *stpcpy(char *</B><I>dest</I><B>, const char *</B><I>src</I><B>);</B>
|
|
|
|
<DD>
|
|
Copy a string from
|
|
<I>src</I>
|
|
|
|
to
|
|
<I>dest</I>,
|
|
|
|
returning a pointer to the end of the resulting string at
|
|
<I>dest</I>.
|
|
|
|
<DT id="7"><B>char *strcat(char *</B><I>dest</I><B>, const char *</B><I>src</I><B>);</B>
|
|
|
|
<DD>
|
|
Append the string
|
|
<I>src</I>
|
|
|
|
to the string
|
|
<I>dest</I>,
|
|
|
|
returning a pointer
|
|
<I>dest</I>.
|
|
|
|
<DT id="8"><B>char *strchr(const char *</B><I>s</I><B>, int </B><I>c</I><B>);</B>
|
|
|
|
<DD>
|
|
Return a pointer to the first occurrence of the character
|
|
<I>c</I>
|
|
|
|
in the string
|
|
<I>s</I>.
|
|
|
|
<DT id="9"><B>int strcmp(const char *</B><I>s1</I><B>, const char *</B><I>s2</I><B>);</B>
|
|
|
|
<DD>
|
|
Compare the strings
|
|
<I>s1</I>
|
|
|
|
with
|
|
<I>s2</I>.
|
|
|
|
<DT id="10"><B>int strcoll(const char *</B><I>s1</I><B>, const char *</B><I>s2</I><B>);</B>
|
|
|
|
<DD>
|
|
Compare the strings
|
|
<I>s1</I>
|
|
|
|
with
|
|
<I>s2</I>
|
|
|
|
using the current locale.
|
|
<DT id="11"><B>char *strcpy(char *</B><I>dest</I><B>, const char *</B><I>src</I><B>);</B>
|
|
|
|
<DD>
|
|
Copy the string
|
|
<I>src</I>
|
|
|
|
to
|
|
<I>dest</I>,
|
|
|
|
returning a pointer to the start of
|
|
<I>dest</I>.
|
|
|
|
<DT id="12"><B>size_t strcspn(const char *</B><I>s</I><B>, const char *</B><I>reject</I><B>);</B>
|
|
|
|
<DD>
|
|
Calculate the length of the initial segment of the string
|
|
<I>s</I>
|
|
|
|
which does not contain any of bytes in the string
|
|
<I>reject</I>,
|
|
|
|
<DT id="13"><B>char *strdup(const char *</B><I>s</I><B>);</B>
|
|
|
|
<DD>
|
|
Return a duplicate of the string
|
|
<I>s</I>
|
|
|
|
in memory allocated using
|
|
<B><A HREF="/cgi-bin/man/man2html?3+malloc">malloc</A></B>(3).
|
|
|
|
<DT id="14"><B>char *strfry(char *</B><I>string</I><B>);</B>
|
|
|
|
<DD>
|
|
Randomly swap the characters in
|
|
<I>string</I>.
|
|
|
|
<DT id="15"><B>size_t strlen(const char *</B><I>s</I><B>);</B>
|
|
|
|
<DD>
|
|
Return the length of the string
|
|
<I>s</I>.
|
|
|
|
<DT id="16"><B>char *strncat(char *</B><I>dest</I><B>, const char *</B><I>src</I><B>, size_t </B><I>n</I><B>);</B>
|
|
|
|
<DD>
|
|
Append at most
|
|
<I>n</I>
|
|
|
|
bytes from the string
|
|
<I>src</I>
|
|
|
|
to the string
|
|
<I>dest</I>,
|
|
|
|
returning a pointer to
|
|
<I>dest</I>.
|
|
|
|
<DT id="17"><B>int strncmp(const char *</B><I>s1</I><B>, const char *</B><I>s2</I><B>, size_t </B><I>n</I><B>);</B>
|
|
|
|
<DD>
|
|
Compare at most
|
|
<I>n</I>
|
|
|
|
bytes of the strings
|
|
<I>s1</I>
|
|
|
|
and
|
|
<I>s2</I>.
|
|
|
|
<DT id="18"><B>char *strncpy(char *</B><I>dest</I><B>, const char *</B><I>src</I><B>, size_t </B><I>n</I><B>);</B>
|
|
|
|
<DD>
|
|
Copy at most
|
|
<I>n</I>
|
|
|
|
bytes from string
|
|
<I>src</I>
|
|
|
|
to
|
|
<I>dest</I>,
|
|
|
|
returning a pointer to the start of
|
|
<I>dest</I>.
|
|
|
|
<DT id="19"><B>char *strpbrk(const char *</B><I>s</I><B>, const char *</B><I>accept</I><B>);</B>
|
|
|
|
<DD>
|
|
Return a pointer to the first occurrence in the string
|
|
<I>s</I>
|
|
|
|
of one of the bytes in the string
|
|
<I>accept</I>.
|
|
|
|
<DT id="20"><B>char *strrchr(const char *</B><I>s</I><B>, int </B><I>c</I><B>);</B>
|
|
|
|
<DD>
|
|
Return a pointer to the last occurrence of the character
|
|
<I>c</I>
|
|
|
|
in the string
|
|
<I>s</I>.
|
|
|
|
<DT id="21"><B>char *strsep(char **</B><I>stringp</I><B>, const char *</B><I>delim</I><B>);</B>
|
|
|
|
<DD>
|
|
Extract the initial token in
|
|
<I>stringp</I>
|
|
|
|
that is delimited by one of the bytes in
|
|
<I>delim</I>.
|
|
|
|
<DT id="22"><B>size_t strspn(const char *</B><I>s</I><B>, const char *</B><I>accept</I><B>);</B>
|
|
|
|
<DD>
|
|
Calculate the length of the starting segment in the string
|
|
<I>s</I>
|
|
|
|
that consists entirely of bytes in
|
|
<I>accept</I>.
|
|
|
|
<DT id="23"><B>char *strstr(const char *</B><I>haystack</I><B>, const char *</B><I>needle</I><B>);</B>
|
|
|
|
<DD>
|
|
Find the first occurrence of the substring
|
|
<I>needle</I>
|
|
|
|
in the string
|
|
<I>haystack</I>,
|
|
|
|
returning a pointer to the found substring.
|
|
<DT id="24"><B>char *strtok(char *</B><I>s</I><B>, const char *</B><I>delim</I><B>);</B>
|
|
|
|
<DD>
|
|
Extract tokens from the string
|
|
<I>s</I>
|
|
|
|
that are delimited by one of the bytes in
|
|
<I>delim</I>.
|
|
|
|
<DT id="25"><B>size_t strxfrm(char *</B><I>dest</I><B>, const char *</B><I>src</I><B>, size_t </B><I>n</I><B>);</B>
|
|
|
|
<DD>
|
|
Transforms
|
|
<I>src</I>
|
|
|
|
to the current locale and copies the first
|
|
<I>n</I>
|
|
|
|
bytes to
|
|
<I>dest</I>.
|
|
|
|
</DL>
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
The string functions perform operations on null-terminated
|
|
strings.
|
|
See the individual man pages for descriptions of each function.
|
|
<A NAME="lbAE"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+index">index</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+rindex">rindex</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+stpcpy">stpcpy</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+strcasecmp">strcasecmp</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+strcat">strcat</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+strchr">strchr</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+strcmp">strcmp</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+strcoll">strcoll</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+strcpy">strcpy</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+strcspn">strcspn</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+strdup">strdup</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+strfry">strfry</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+strlen">strlen</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+strncasecmp">strncasecmp</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+strncat">strncat</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+strncmp">strncmp</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+strncpy">strncpy</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+strpbrk">strpbrk</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+strrchr">strrchr</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+strsep">strsep</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+strspn">strspn</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+strstr">strstr</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+strtok">strtok</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+strxfrm">strxfrm</A></B>(3)
|
|
|
|
<A NAME="lbAF"> </A>
|
|
<H2>COLOPHON</H2>
|
|
|
|
This page is part of release 5.05 of the Linux
|
|
<I>man-pages</I>
|
|
|
|
project.
|
|
A description of the project,
|
|
information about reporting bugs,
|
|
and the latest version of this page,
|
|
can be found at
|
|
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="26"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="27"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="28"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="29"><A HREF="#lbAE">SEE ALSO</A><DD>
|
|
<DT id="30"><A HREF="#lbAF">COLOPHON</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:58 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|