نطاقات
المتغيرات
أفعال

strlen

من cppreference.com
< c | string | byte
<tbody> </tbody>
معرفة في ملف <string.h>
size_t strlen( const char *str );

تحسب طول سلسلة من الحروف.

لا يتم احتساب حرف ‎'\0'‎ الختامي ضمن الطول المُرجع.

معطيات

str - مؤشر على مصفوفة من الحروف تنتهي ب ‎'\0'

القيمة المُرجعة

طول السلسلة المختومة بـ ‎'\0'‎: ‏ ‎str‎.

مثال

#include <string.h>
#include <stdio.h>

int main(void)
{
    const char str[] = "How many characters does this string contain?";

    printf("without null character: %zu\n", strlen(str));
    printf("with null character: %zu\n", sizeof(str));

    return 0;
}

الخرج:

without null character: 45
with null character: 46

أنظر أيضا

Morty Proxy This is a proxified and sanitized view of the page, visit original site.