Hot answers tagged

2

method is 3 chars long and you need at least 4 characters to store the string "GET" {'G', 'E', 'T', '\0'}. so technically your variable method is not actually a string (it doesn't terminate with a '\0'). even if the first 3 characters of method and methodcmp are identical, there's no guarantee that method[3] (which is out of method's bounds) will be storing ...


2

If you fix the missing semicolon that @DinoCoderSaurus mentioned, this works fine. I suspect you hadn't compiled it after writing your function, so the default return false was still being used.


1

There is no problem in assigning it to an integer, the problem is in strlen () and strcmp(), the array of characters s does not end in a '\0', and therefore the function srtcmp does not know where it ends, so it gives us an errored length (Surely it ends when it encounters a zero by chance), we should not use this functions with array of characters but with ...


1

Trying to trick me? That line if(strcasecmp (&path [0],"/") != 0) does not appear in the code you posted. The problem is your usage of strcasecmp. &request_line[0] is "the contents of request_line starting at index 0". What is that? It's the whole request line. If you want to compare the first character of request_line, that would be request_line[0]...


1

The first thing I see is that you are comparing a string, "\n" to a char, the contents of c. This is usually bad. Instead of that, have you considered just checking the equality of two chars, c == '\n' ? Note the single quotes to indicate a char, not double quotes indicating a string. If this answers your question, please click the check mark to accept. ...


Only top voted, non community-wiki answers of a minimum length are eligible