string(3) Library Functions Manualstring(3)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
Standard C library (libc,-lc)
#include <strings.h>strcasecmp(3) Compare two strings, ignoring case.strncasecmp(3) Compare the first bytes of two strings, ignoring case.index(3) Identical tostrchr(3).rindex(3) Identical tostrrchr(3).#include <string.h>stpcpy(3) Copy a string, returning a pointer to the end of the resulting string.strcat(3) Append a string into an existing string.strchr(3) Find the first occurrence of a character in a string.strcmp(3) Compare two strings.strcoll(3) Compare two strings, using the current locale.strcpy(3) Copy a string.strcspn(3) Calculate the length of the initial segment of a string which does not contain any of the rejected bytes.strdup(3) Duplicate a string in memory allocated usingmalloc(3).strfry(3) Randomly swap the characters in a string.strlen(3) Return the length of a string.strncat(3) Append non-null bytes from an array to a string, and null- terminate the result.strncmp(3) Compare the first bytes of two strings.strpbrk(3) Find the first occurrence in a string of one of the bytes in the accepted bytes.strrchr(3) Find the last occurrence of a character in a string.strsep(3) Extract the initial field in a string that is delimited by one of the delimiter bytes.strspn(3) Calculate the length of the initial segment of a string that consists entirely of accepted bytes.strstr(3) Find the first occurrence of a substring in a string.strtok(3) Extract tokens from a string that are delimited by one of the delimiter bytes.strxfrm(3) Transforms a string to the current locale and copies the first bytes to a buffer.strncpy(3) Fill a fixed-size buffer with leading non-null bytes from a source array, padding with null bytes as needed.
The string functions perform operations on null-terminated strings. See the individual man pages for descriptions of each function.
bstring(3),stpcpy(3),strcasecmp(3),strcat(3),strchr(3),strcmp(3),strcoll(3),strcpy(3),strcspn(3),strdup(3),strfry(3),strlen(3),strncasecmp(3),strncat(3),strncmp(3),strncpy(3),strpbrk(3),strrchr(3),strsep(3),strspn(3),strstr(3),strtok(3),strxfrm(3)
This page is part of theman-pages (Linux kernel and C library user-space interface documentation) project. Information about the project can be found at ⟨https://www.kernel.org/doc/man-pages/⟩. If you have a bug report for this manual page, see ⟨https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/tree/CONTRIBUTING⟩. This page was obtained from the tarball man-pages-6.15.tar.gz fetched from ⟨https://mirrors.edge.kernel.org/pub/linux/docs/man-pages/⟩ on 2025-08-11. If you discover any rendering problems in this HTML version of the page, or you believe there is a better or more up- to-date source for the page, or you have corrections or improvements to the information in this COLOPHON (which isnot part of the original manual page), send a mail to man-pages@man7.orgLinux man-pages 6.15 2025-05-17string(3)Pages that refer to this page:bstring(3), strcasecmp(3), strchr(3), strcmp(3), strcoll(3), strcpy(3), strdup(3), strfry(3), strlen(3), strncat(3), strpbrk(3), strsep(3), strspn(3), strstr(3), strtok(3), strxfrm(3), string_copying(7)
HTML rendering created 2025-09-06 byMichael Kerrisk, author ofThe Linux Programming Interface. For details of in-depthLinux/UNIX system programming training courses that I teach, lookhere. Hosting byjambit GmbH. | ![]() |