Monday, 23 January 2012

Write a c program to count the character in a string

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

void main()
{
    char a[100];
    int i,ct=0,l;
    clrscr();
    printf("Enter the string\n");
    gets(a);
    l=strlen(a);
    for(i=0;i<l;i++)
    {
        ct=ct+1;
    }
    printf("No of Charater in a string is=%d",ct);
    getch();
}

No comments:

Post a Comment