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()/*from w w  w  . j a  v a  2  s .c  o  m*/
{
    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