RAD Studio
ContentsIndex
PreviousUpNext
strlen, _mbslen, wcslen, _mbstrlen

Header File 

string.h, mbstring.h, stdlib.h 

Category 

Memory and String Manipulation Routines, Inline Routines 

Prototype 

size_t strlen(const char *s); 

size_t wcslen(const wchar_t *s); 

size_t _mbslen(const unsigned char *s); 

size_t _mbstrlen(const char *s) 

Description 

Calculates the length of a string. 

strlen calculates the length of s. 

_mbslen and _mbstrlen test the string argument to determine the number of multibyte characters they contain.  

_mbstrlen is affected by the LC_CTYPE category setting as determined by the setlocale function. The function tests to determine whether the string argument is a valid multibyte string. 

_mbslen is affected by the code page that is in use. This function doesn’t test for multibyte validity. 

Return Value 

strlen returns the number of characters in s, not counting the null-terminating character. 

Example  

#include <stdio.h>
#include <string.h>
int main(void)
{
   char *string = "CodeGear";
   printf("%d\n", strlen(string));
   return 0;
}

Portability

 
POSIX 
Win32 
ANSI C 
ANSI C++ 
strlen  
+  
+  
+  
+  
_mbslen  
 
+  
 
 
wcslen  
 
+  
+  
+  
_mbstrlen  
 
+  
 
 
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!