how to force a buffer to behave like a string in C?

1

I'm getting a buffer from the internet, I believe that to traverse this buffer and find the last character, you need to find the character '\ 0'. But there is no '\ 0' in a buffer.

Can I force this buffer to behave like a string?

    
asked by anonymous 24.06.2015 / 22:34

1 answer

2

Adds p% of% to the buffer. But attention to binary data !!

length = recv(socket, buffer, sizeof buffer - 1, 0);
buffer[length] = 0; // adiciona terminador
    
24.06.2015 / 22:54