C - Count total character in a char array

Description

Count total character in a char array

Demo

#include <stdio.h>
#include <ctype.h>

int main()/*  w ww  .  java 2  s  .  c  om*/
{
    char phrase[] = "This is a Test";

    int index;
     index = 0;
    while(phrase[index])
    {
        index++;
    }

    printf("\"%s\"\n",phrase);
    puts("Statistics:");
    printf("%d total characters\n",index);

    return(0);
}

Result

Related Topic