#include <string.h> size_t strlen(const char *str);
strlen
returns the length of a null-terminated character string
str
.
strlen
to return
int
rather than size_t
.
<string.h>
is included (by an #include
statement) and strlen
is not undefined (by an #undef
statement), strlen
generates inline code. If the argument to
strlen
is a constant, the length is evaluated during compilation,
and no code is generated for the function.
#include <string.h> #include <stdio.h> #define MAXLINE 100 main() { char line[MAXLINE+1]; puts("Enter some text (at least 2 characters):"); gets(line); puts("The last half of your text is:"); puts(line + (strlen(line)/2)); }
mblen
Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.