Tuesday 1 October 2013

Count The Characters Of User Entered Text String

Just to bring my post count to 45. This counts the characters in a user entered string.

#include <stdio.h>
#include <strings.h>

int main()
{
    char word[1000];
    int i=0;

    printf("Enter text: ");
    gets(word);

    while(word[i]!='\0')
    {
        i++;
    }
    printf("Text is %i character/s long.",i);
    return 0;
}

No comments:

Post a Comment