79285158

Date: 2024-12-16 15:23:43
Score: 1.5
Natty:
Report link

Thanks everyone. @Lundin , your advice is taken. I subsequently realised the check for '\0' should happen after the for loop terminates. So the modified code is

char * strstrci (char *s, char *p)
{
    int i, j;
    for (i = 0; s[i] != '\0'; i++)
    {
        if (s[i] == *p || s[i] == *p + 32 || s[i] == *p - 32)
        {
            for (j = 1; s[i + j] == p[j] ||  s[i + j] == p[j] + 32 ||  s[i + j] == p[j] - 32; j++);
            
                if (p[j] == '\0')
                    return &s[i];
        }
    }
    return NULL;
}

This works for all cases.

Reasons:
  • Blacklisted phrase (0.5): Thanks
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @Lundin
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Vinayak Deshmukh