You can get the length of a string using the
This function is declared in the header file `string.h'.
strlenfunction returns the length of the null-terminated string s. (In other words, it returns the offset of the terminating null character within the array.)
strlen ("hello, world") => 12
When applied to a character array, the
strlen function returns
the length of the string stored there, not its allocation size. You can
get the allocation size of the character array that holds a string using
char string = "hello, world"; sizeof (string) => 32 strlen (string) => 12
Go to the first, previous, next, last section, table of contents.