strlen


strlen

Obtains the length of a string

 #include <string.h> size_t strlen ( const char *s  ); 

The strlen( ) function calculates the length of the string addressed by its argument s. The length of a string is the number of characters in it, not counting the terminating null character ('\0').

Example

 char line[1024] = "This string could easily be hundreds of characters long." char *readptr = line; int columns = 80; // While the text is longer than a row: while ( strlen( readptr ) > columns ) {  // print a row with a backslash at the end:   printf( "%.*s\\", columns-1, readptr);   readptr += columns -1; }  //  Then print the rest with a newline at the end: printf( "%s\n", readptr ); 

See Also

wcslen( )



C(c) In a Nutshell
C in a Nutshell (In a Nutshell (OReilly))
ISBN: 0596006977
EAN: 2147483647
Year: 2006
Pages: 473

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net