Monday 9 September 2013

c program to find length of a string without using "strlen" function

#include<stdio.h>
 #include<conio.h>
 void main()
 {
char s[20];
int m;
clrscr();
printf("enter a string..");
gets(s);
for(m=0;s[m]!='\0';m++);
printf("\nlength of your string is:%d\n",m+1); /*last character is a null character */
getch();
}

No comments:

Post a Comment