I'm going to have a test in next week. And in the sheet they say that "You can't use strlen() in test" How can I make it.
Can use only ONLY!!!
I'm going to have a test in next week. And in the sheet they say that "You can't use strlen() in test" How can I make it.
Can use only ONLY!!!
size_t my_strlen(const char *s){
const char *p=s;
while(*p)
++p;
return p-s;
}
Try something like this.
#include<stdio.h>
int strlen(const char* temp)
{
int i=0;
while(*(temp++)) ++i;
return i;
}
int main()
{
char *text = "Hello World";
printf("%d",strlen(text));
return 1;
}
unsigned long mystrlen( const char *szString )
{
unsigned long ulLen = 0;
While( szString[0]){ szString++; ulLen++;}
return ulLen;
}