strlen() function in c Last Updated : 29 May, 2023 Comments Improve Suggest changes 30 Likes 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 B bansal_rtk_ Follow 30 Improve B bansal_rtk_ Follow 30 Improve Article Tags : Misc C Language C-String C-Library Explore C BasicsC Language Introduction6 min readIdentifiers in C3 min readKeywords in C2 min readVariables in C4 min readData Types in C3 min readOperators in C8 min readDecision Making in C (if , if..else, Nested if, if-else-if )7 min readLoops in C6 min readFunctions in C5 min readArrays & StringsArrays in C4 min readStrings in C5 min readPointers and StructuresPointers in C7 min readFunction Pointer in C6 min readUnions in C3 min readEnumeration (or enum) in C5 min readStructure Member Alignment, Padding and Data Packing8 min readMemory ManagementMemory Layout of C Programs5 min readDynamic Memory Allocation in C7 min readWhat is Memory Leak? How can we avoid?2 min readFile & Error HandlingFile Handling in C11 min readRead/Write Structure From/to a File in C3 min readError Handling in C8 min readUsing goto for Exception Handling in C4 min readError Handling During File Operations in C5 min readAdvanced ConceptsVariadic Functions in C5 min readSignals in C language5 min readSocket Programming in C8 min read_Generics Keyword in C3 min readMultithreading in C9 min read Like