| PREV |
Write your own .... |
NEXT |
| |
(30 / 301) |
|
|
|
|
Write a C program to implement the strlen() function
|
The prototype of the strlen() function is...
size_t strlen(const char *string);
Here is some C code which implements the strlen() function....
int my_strlen(char *string)
{
int length;
for (length = 0; *string != '\0', string++)
{
length++;
}
return(length);
}
Also, see another example
int my_strlen(char *s)
{
char *p=s;
while(*p!='\0')
p++;
return(p-s);
}
|
| PREV |
COMMENTS INDEX PRINT |
NEXT |
Last updated:
November 3, 2005
www.cracktheinterview.com - Your destination for the most common IT interview questions, answers, frequently asked interview questions (FAQ), C Programs, C Datastructures for technical interviews conducted by the top IT companies around the world!
|
|
|