0

Finally I got Pset6 down to only one failing test.

:( Requesting /test/ outputs /test/index.html

As per the spec my program loads the index.html file in 'test' folder, which shows the Youtube video.

but I guess the test expects a different output. Below the my implementation of Indexes

char* indexes(const char* path)
{
char* html = "index.html";
char* php = "index.php";

char* index = calloc(1, strlen(path) * sizeof(BYTE) + strlen(php) * sizeof(BYTE));
strcpy(index, path); 
strcat(index, php);

if( access( index, F_OK ) != -1 ) {
    return index;
} 

index = NULL;

index = realloc(index, strlen(path) * sizeof(BYTE) + strlen(html) * sizeof(BYTE));
strcpy(index, path); 
strcat(index, html);

if( access( index, F_OK ) != -1 ) {
    return index;
} else {
    free(index);
     return NULL;
}
}

can anyone point me into the right direction? thx

0

It boils down to something like this:

enter image description here

If this solves your problem, please click the check mark to accept the answer.

| improve this answer | |
  • ooh, I should have seen that one coming.... Thank YOU! – Arne Koning Dec 9 '16 at 13:33
  • one more question about this function. It works now but Valgrind shows a memory leakage. Although I think I have freed memory correctly. – Arne Koning Dec 9 '16 at 19:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .