Mar
25
//get length of string in C
#include<stdio.h>
void main(){
char name[100];
int i;
printf(“Enter Your name: “);
//scanf(“%s”,name);
gets(name);
printf(“%d\n”,sizeof(name));
printf(“Your name is: %s\n”,name);
for(i=0;name[i]!=’\0′;i++);
printf(“Length of string: %d”,i);
}
Leave a Reply
No Comments