This is the another method, we are using string.h
#include<stdio.h>
#include<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:


0 comments:
Post a Comment