isnt it better to write that as:
const char* response = "HTTP/1.1 200 OK\nContent-Type: text/html\n\nlol"; ?
Having the string in a writable buffer when you have no intention of modifying the string seems like not a very good idea.
Any decent compiler will evaluate "strlen(response)" at compile time and hence there will be no run time penalty here.
Any decent compiler will also notice this and put the string literal in the .RODATA section. Using "const" doesn't really make a difference, it's more of a hint for the compiler.
It really doesn't make any difference in this case.
[1] Where future developers includes me - I'll forget what I wrote in six months or less.
[0] http://stackoverflow.com/questions/2288856/when-implementing...
I haven't read the whole thing but I like this bit:
> There are many algorithms that are best written using an exit from the middle of a loop. If not written in this fashion, techniques such as the traditional “priming” of a loop must be used. For example, in reading a file:
read(a, b, c)
WHILE NOT eof DO
{ process a, b, & c }
read(a, b, c)
END WHILE
LOOP
read(a, b, c)
WHEN eof EXIT
{ process a, b, & c }
END LOOP
> The example on the left [top] shows the priming of a loop. This requires duplication of the READ statement or, in other cases, creation of a subprogram to eliminate the duplication, both of which are undesirable. As well, loop priming can be done an arbitrary distance before the beginning of the loop making the program difficult to read as the priming statement(s) is critical to the understanding of the loop.