strlen, _fstrlen

Description

Get the length of a string.

#include <string.h> Required only for function declarations  

size_t strlen( const char *string );

size_t _fstrlen( const char __far *string );

string Null-terminated string  

Remarks

The strlen and _fstrlen functions return the length in bytes of string, not including the terminating null character ('\0').

The _fstrlen function is a model-independent (large-model) form of the strlen function. The behavior and return value of _fstrlen are identical to those of the model-dependent function strlen, with the exception that the argument is a far pointer.

Return Value

These functions return the string length. There is no error return.

Compatibility

strlen

Standards:ANSI, UNIX

16-Bit:DOS, QWIN, WIN, WIN DLL

32-Bit:DOS32X

_fstrlen

Standards:None

16-Bit:DOS, QWIN, WIN, WIN DLL

32-Bit:None

Example

/* STRLEN.C */

#include <string.h>

#include <stdio.h>

#include <conio.h>

#include <dos.h>

void main( void )

{

char buffer[61] = "How long am I?";

int len;

len = strlen( buffer );

printf( "'%s' is %d characters long\n", buffer, len );

}

Output

'How long am I?' is 14 characters long