C - strlen()-string length

<<Previous

Next >>





This function is used to determine the length of the string. It usually counts the number of characters present in the string except the NULL character. Finally it will return integer value as an output.

Syntax:
	int *strlen(const char *str);

Note: size_t treats as an integer type.

Following is an example program using strlen()

#include<stdio.h>

#include<string.h>


main()
{
  char src[]={’W’,‘E’,‘L’,‘C’, ‘O’,‘M’,‘E’};
  int result;
  clrscr();
  printf(" The source string is %s ",src);
  result = strlen(src);
  printf(" The length of the string is %d ",result);
  return(0);
}

Output:

The source string is WELCOME
The length of the string is 7

<< Previous

Next >>







C - strlen()-string length

<<Previous

Next >>





This function is used to determine the length of the string. It usually counts the number of characters present in the string except the NULL character. Finally it will return integer value as an output.

Syntax:
	int *strlen(const char *str);

Note: size_t treats as an integer type.

Following is an example program using strlen()

#include<stdio.h>

#include<string.h>


main()
{
  char src[]={’W’,‘E’,‘L’,‘C’, ‘O’,‘M’,‘E’};
  int result;
  clrscr();
  printf(" The source string is %s ",src);
  result = strlen(src);
  printf(" The length of the string is %d ",result);
  return(0);
}

Output:

The source string is WELCOME
The length of the string is 7

<< Previous

Next >>







Learn about Hashing and Hash table

Learn Expression Tree

OS Kernel Architecture

OS Arcitecture of Windows, Linux and MacOS

Learn OS scheduling Algorithms