Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 10074

indexes() is a function with CS50's mostly-implemented server.c program in PSET6. It must check, in order, whether index.php or index.html exists inside of path. It returns to path to match if so, else it returns NULL.

3 votes
Accepted

Pset6 problem in indexes and load function

indexes Your allocation for path2 is wrong char* path2 = (char*)malloc(sizeof(strlen(php) + strlen(html) + 1)); First, the sizeof has got to go. …
DinoCoderSaurus's user avatar
2 votes

error in load and indexes function

Reread the specification for indexes in the instructions. … Complete the implementation of indexes in such a way that the function, given a /path/to/a/directory, returns /path/to/a/directory/index.php if index.php actually exists therein, or /path/to/a/directory …
DinoCoderSaurus's user avatar
1 vote
Accepted

indexes function again

The function signature of strstr is char *strstr(const char *haystack, const char *needle) Since you have declared needle a const char*, you are violating the contract. I recommend further re …
DinoCoderSaurus's user avatar
1 vote

Indexes function playing a sort of infinite loop

Response to edit#1: NB: The code post turned char* html = malloc(12); into this char html = malloc(12); which was only confusing for a little while :) A major problem you are encountering is your …
DinoCoderSaurus's user avatar
1 vote
Accepted

Pset6: server is functional but still failing a few checks

How many bytes have you allocated to pathcopy? How many bytes are you trying to stuff in it? (Ditto pathcopy2). Once you fix that, make sure newpath is sized properly. Also here's more trouble your …
DinoCoderSaurus's user avatar
1 vote
Accepted

Images Not Loading in Server.c, but Getting 200 OK Response

EDIT Sorry again for the misdirect. The elusive 1 eludes me at least once a day. This strncpy(storage, buffer, count); is causing a problem. Content can be anything. And content can have bytes with v …
DinoCoderSaurus's user avatar
1 vote
Accepted

Pointer to char comes back empty

Scope. Pointers. Look at the difference between the way you create abs_path and the way you create query. This strncpy(abs_path, reqtar, aplen); changes the contents of the memory that abs_path points …
DinoCoderSaurus's user avatar
1 vote
Accepted

Pset6 Unexpected end of input

Unexpected end of input Indicates a timeout on the check50 server. It has not processed your request. The only advice is "try again later". error 404 Assuming you mean the "non_existAnt" fi …
DinoCoderSaurus's user avatar
1 vote

Pset6 problem in indexes and load function

Other things from a quick readthrough: This didn't work in parse, it's not gonna work in indexes. … There are (other) fundamental problems in indexes. You need to go through it carefully and critically because it is not doing what the spec requires. …
DinoCoderSaurus's user avatar
1 vote
Accepted

pset6 server.c 403 forbidden for "/", problems for lookup and indexes

Hint: This line in indexes if (access(phpcheck, F_OK)) (and the other access) is wrong. Suggestion: Read man access. Pay special attention to the RETURN section. access returns an int. …
DinoCoderSaurus's user avatar
1 vote

PSET6 Indexes Doesn't Work

Assuming 1) your directory structure is like this, 2) you started server with the public directory as your document root, and 3) your indexes function is correct, a request to https://ide50-username.cs50 … so it is expecting indexes() to do the allocation for the returned string. …
DinoCoderSaurus's user avatar
1 vote
Accepted

PSET6 Indexes wrong condition followed

gdb hint: inspect the value of index in main after you return from indexes. The real problem comes here: char* ptr_best = try1; (and try2 too). …
DinoCoderSaurus's user avatar
1 vote
Accepted

pset6 | Server.c | load and indexes doesn't work

indexes Read the man page on access and pay special attention to the return value. Spoiler: it ain't a bool. …
DinoCoderSaurus's user avatar
1 vote
Accepted

Pset 6 failing checks on indexes

sizeof bad. char* temp_path = malloc(sizeof(path)); path is a pointer. sizeof a pointer is 4 or 8 depending on architecture. Looks like you want the length of the strings, which is a different functio …
DinoCoderSaurus's user avatar
1 vote
Accepted

check50 fails on pset6 possibly indexes function

The old sizeof trap. strlen(path) + strlen(php) + 1 returns an integer. sizeof an integer is 4. In two places. Do not use sizeof. Here is a good explanation. Think about this, if you allocate dir for …
DinoCoderSaurus's user avatar

15 30 50 per page