ProAnswers.org

Write a C program to count the number of characters in a given string?

 #include<stdio.h>

#include<conio.h>

#include<string.h>

void main()

{

char text [20];

int len;

clrscr();

printf(“type text below\n”);

gets(text);

len=strlen(text);

printf(“Length of string=%d”, len);

getch();

}

Output:

Type text below

Sam

Length of the string=3