F How to find length of a string by using function in C program? | CodeTheta

How to find length of a string by using function in C program?

January 17, 2014


/* http://native-code.blogspot.com */

#include<stdio.h>

#include<conio.h>



int myfunc(char *s)

{

int len=0;

while(*s!='\0')

{



len++;

s++;



}

return(len);

}



void main()

{



char ch[10];

printf(" /* http://native-code.blogspot.com */    \n\n please enter string: ");

gets(ch);

int i;

i=myfunc(ch);

printf("\n length=%d",i);

getch();

}

/* http://native-code.blogspot.com */ 

Post a Comment