Close Menu
    Facebook X (Twitter) Instagram
    Command Linux
    • About
    • How to
      • Q&A
    • OS
      • Windows
      • Arch Linux
    • AI
    • Gaming
      • Easter Eggs
    • Statistics
    • Blog
      • Featured
    • MORE
      • IP Address
      • Man Pages
    • Write For Us
    • Contact
    Command Linux
    Home - man page - STRNLEN

    STRNLEN

    WillieBy WillieFebruary 11, 2026Updated:February 11, 2026No Comments1 Min Read
     

    NAME

    strnlen – determine the length of a fixed-size string  

    SYNOPSIS

    #include <string.h>
    
    size_t strnlen(const char *s, size_t maxlen);
    

    Feature Test Macro Requirements for glibc (see feature_test_macros(7)):

    strnlen():

    Since glibc 2.10:
    _XOPEN_SOURCE >= 700 || _POSIX_C_SOURCE >= 200809L
    Before glibc 2.10:
    _GNU_SOURCE
     

    DESCRIPTION

    The strnlen() function returns the number of bytes in the string pointed to by s, excluding the terminating null byte (‘\0’), but at most maxlen. In doing this, strnlen() looks only at the first maxlen bytes at s and never beyond s+maxlen.  

    RETURN VALUE

    The strnlen() function returns strlen(s), if that is less than maxlen, or maxlen if there is no null byte (‘\0’) among the first maxlen bytes pointed to by s.  

    ATTRIBUTES

     

    Multithreading (see pthreads(7))

    The strnlen() function is thread-safe.  

    CONFORMING TO

    POSIX.1-2008.  

    COLOPHON

    This page is part of release 3.74 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at http://www.kernel.org/doc/man-pages/.

    Willie
    • Website

    Willie has over 15 years of experience in Linux system administration and DevOps. After managing infrastructure for startups and enterprises alike, he founded Command Linux to share the practical knowledge he wished he had when starting out. He oversees content strategy and contributes guides on server management, automation, and security.

    Related Posts

    NTFS-3G

    April 21, 2026

    CAT

    April 21, 2026

    RPCBIND

    April 21, 2026

    SYSCTL

    April 21, 2026
    Top Posts

    ENCHANT-LSMOD

    April 4, 2026

    VIM

    February 13, 2026

    GIT-MERGE

    March 30, 2026

    FTP

    February 11, 2026
    • Home
    • Contact Us
    • Privacy Policy
    • Terms of Use

    Type above and press Enter to search. Press Esc to cancel.