strlen
The strlen function returns the number of characters contained in a null terminated string. The function assumes that there is a null character at the end of the string, and if the string is not null terminated the result is undefined.
The strlen function expects only one argument, a pointer to the string that will be measured.
The following code shows an example of strlen use:
#include#include int main() { char *str = "hello world"; int str_length; str_length = strlen(str); printf("the length of the string is now '%s'\n", dest); return 0; }
Article created on 2008-08-19 22:16:29
Post a comment