0

Short question. Is that doable ?

 query = " \0";

I mean, can I assign a Null terminator to the string consisting of a space " " in this manner? Where query is a char* query. p.s. printf seems to only print a space character, so probably it is working, just want to double check

1 Answer 1

0

According to the spec, there is never a case where query will have the value of "space".

For instance, if request-target is /hello.php or /hello.php?, then query should have a value of "". And if request-target is /hello.php?q=Alice, then query should have a value of q=Alice.

The "" is quotequote, nothing in between.

This syntax query = " \0"; is not correct. When you set a variable to a string literal, C will "automagically" null-terminate it, so you should not. Plus, as per the above, this is a check50 failure waiting to happen.

3
  • Well this comes from problem set specs : Store at the address in query the query substring from request-target. If that substring is absent (even if a ? is present), then query should be "", thereby consuming one byte, whereby query[0] is '\0'. Does that mean no space than right?
    – Kamil Kug
    Commented Sep 25, 2016 at 18:39
  • Correct. No space. quotequote. Commented Sep 25, 2016 at 18:56
  • Thanks. Just misunderstanding than:)
    – Kamil Kug
    Commented Sep 25, 2016 at 19:07

You must log in to answer this question.

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