strlen - C string.h

C examples for string.h:strlen

Type

function

From

<cstring> 
<string.h>

Description

Returns the length of the C string str.

Prototype

size_t strlen ( const char * str );

Parameters

Parameter Description
str C string.

Return Value

The length of string.

Demo Code


#include <stdio.h>
#include <string.h>

int main ()/* w ww .  jav a 2 s  .  co m*/
{
  char szInput[256];
  printf ("Enter a sentence: ");
  gets_s (szInput);
  printf ("The sentence entered is %u characters long.\n",(unsigned)strlen(szInput));
  return 0;
}

Related Tutorials