its been a while i have been trying to get my index function right. I know I am close because there is only one error in check50.. The code looks fine to me. I can't figure out what is wrong with it.. Please help.. my code for indexes function is below...
char* indexes(const char* path)
{
int n = strlen(path);
char* path_html = "index.html";
char* path_php = "index.php";
char* copy_html = malloc(sizeof(BYTE) * (n + strlen(path_html)));
char* copy_php = malloc (sizeof(BYTE) * (n + strlen(path_php)));
for (int i = 0, n =strlen(path); i < n; i++)
{
copy_html[i] = path[i];
copy_php[i] = path[i];
}
strcat(copy_php, path_php);
strcat(copy_html, path_html);
if (!access(copy_php, F_OK))
{
free(copy_html);
return copy_php;
}
free(copy_php);
if (!access(copy_html, F_OK))
{
return copy_html;
}
free(copy_html);
return NULL;
}
the error I get :(.. https://sandbox.cs50.net/checks/236727c2ec164277b91f994c7360b7e0
Thank you.