C program to print length of string

         C program to print length of string


include<stdio.h>
void main(){
char str[15];
int=0;
printf("Enter any string :\t"); 
 scanf("%s",&str);
while(str[i]!='\0')
{
i++;
printf("\nLength of string :\t%d",i);
getch();
} 

Output:-
Enter any string :      ankit c guru
Length of string :      12

Note:- Compiler will also count blank spaces between words while compiling.

Comments

Popular posts from this blog