In my project I’m currently trying to return a HTTP response from a server to a client in C. My response character array (char*) is “HTTP/1.0 200 OKn”. I store this in a buffer with ample capacity (100 bytes). When I actually try and go to output the buffer with printf like so,
printf("%s n", buffer);
The result in my console looks something like this
HTTP/1.0Д)??
What could be the possible issue for why the entire buffer is not correctly written?
I have tried adding more than a single string formation when I use printf()
For context, I am printing this buffer out on the server where it is generated, after copying the desired string to it and the output shows as expected
HTTP/1.0 200 OK
However, when I send this buffer through a socket back to the client, the buffer becomes corrupted when it encounters the first space after ‘HTTP/1.0’
Any help is greatly appreciated.