C Program to calculate length of given string in C without using STRLEN function

C Program to calculate length of given string in C without using STRLEN function



main ( )
{
char s1[6] = “abcde ”;
int cnt = 0;
cnt = cnt_str(s1);
printf( “ total characters are %d \n”, cnt);
}

int cnt_str(char s1[]);
{
int cn = 0;
while ( (cn < 6) && s1[cn]! = ‘\0’) cn++; return(cn); }

No comments:

Post a Comment