strlen
من cppreference.com
<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
أنظر أيضا
مقالة مرجع C++ عن strlen
|