calculating length of a string
#include <stdio.h>
int strlen_mine(char *str)
{
int len=0;
char * ptr=str;
while(*ptr!='\0')
{
ptr++;
len++;
}
printf("The length of the string is:%d\n",len);
}
int main(){
char c[30];
printf("Enter the string\n");
//scanf("%s",c);
gets(c);
strlen_mine(c);
return 0;
}
Comments
Post a Comment