Friday, 22 June 2012

write a c program calculate the length of string without using standard function


/*write a c program calculate the length of string
without using standard function */
#include<stdio.h>
#include<conio.h>
void main()
{
char str1[30];
int i;
clrscr();
printf("\nenter the string:\n");
gets(str1);
i=0;
while(str1[i]!='\0')
{
i++;
}
printf("the length of string is :%d\n",i);
getch();
}
/*
enter the string:                                                              
peersaab
the length of string is :8
                              */

No comments: