Another Code to Count Char in A Sentence

Saturday, October 10, 2009

This is the another method, we are using string.h


char line[100]; //max 100 chars of input

int main(void){
    printf("Enter the sentence: \n");
    fgets(line, sizeof(line), stdin);

    printf("The length of the sentence is: %d\n", strlen(line));
    return 0;

And this is the result:


Post a Comment

Copyright © Welcome