strlen() function in c Last Updated : 29 May, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report The strlen() function in C calculates the length of a given string. The strlen() function is defined in string.h header file. It doesn't count the null character '\0'. Syntax of C strlen() The syntax of strlen() function in C is as follows: size_t strlen(const char* str);Parameters The strlen() function only takes a single parameter. str: It represents the string variable whose length we have to find.Return ValueThis function returns the integral length of the string passed.C strlen() FunctionExample of C strlen() The below programs illustrate the strlen() function in C: C // c program to demonstrate // example of strlen() function. #include <stdio.h> #include <string.h> int main() { // defining string char str[] = "GeeksforGeeks"; // getting length of str using strlen() int length = strlen(str); printf("Length of string is : %d", length); return 0; } OutputLength of string is : 13Important Points about strlen() The following points should be kept in mind while using strlen(): strlen() does not count the NULL character '\0'.The time complexity of strlen() is O(n), where n is the number of characters in the string.Its return type is size_t ( which is generally unsigned int ). Comment More infoAdvertise with us Next Article strlen() function in c B bansal_rtk_ Follow Improve Article Tags : Misc C Language C-String C-Library Practice Tags : Misc Similar Reads strol() function in C++ The strtol() function in C++ interprets the contents of a string as an integral number of the specified base and return its value as a long int.This function also sets an end pointer that points to the first character after the last valid numeric character of the string, if there is no such characte 3 min read strspn() function in C The strspn() function returns the length of the initial substring of the string pointed to by str1 that is made up of only those character contained in the string pointed to by str2. Syntax : size_t strspn(const char *str1, const char *str2) str1 : string to be scanned. str2 : string containing the 1 min read strrev() function in C The strrev() function is a built-in function in C and is defined in string.h header file. The strrev() function is used to reverse the given string. Syntax:char *strrev(char *str);Parameter:str: The given string which is needed to be reversed.Returns: This function doesn't return anything but the re 2 min read strnset() function in C The strnset() function is a builtin function in C and it sets the first n characters of a string to a given character. If n is greater than the length of string, the length of string is used in place of n. Syntax: char *strnset(const char *str, char ch, int n); Parameters: str: This is the original 2 min read mbrlen() function in C/C++ The mbrlen() function in C/C++ determines the size in bytes, of the remainder of the multibyte character whose first byte is pointed to by str, given the current conversion state ps. The behavior of this function depends on the LC_CTYPE category of the selected C locale. Syntax: size_t mbrlen( const 3 min read Like