i want to return a pointer to a part of array

i m making strchr() function, i need to return a pointer that points somewhere in the array,my code here does not work:

char *astrchr(const char *s,int c)
{
char *p=NULL;

for(int i=0;i< astrlen(s); i++)
{
if(s[i]==c)
{
return p=&s[i];

}

}


return p;

}

it gives an error "cannot convert from char to char*"

i asked my friend he told me to use" return (char *)(s+i) ; " i dont understand it,i want to do it my way!
Your friend is right but if you want to use subscripting the right syntax should be &(s[i]) and remember that s is a const char*
Topic archived. No new replies allowed.