Q:

read socket from C

When I use read() socket to retrieval bytes from server I found something unexpected in the chars.
Below is my code:
Char buf[80];
Char output[80];
if ( (count = read(socket_d, buf, 80)) == -1) {
        perror("Error on read call");
        exit(1);
    }
strcat(output, buf);
printf("Client read %d bytes\n", count);       
while (count==80) {
    memset(&buf, 0, sizeof(buf));
    if ( (count = read(socket_d, buf, 80)) == -1) {
        perror("Error on read call");
        exit(1);
    }
    printf("Client read %d bytes\n", count);
    strcat(output, buf);
}
/* print the received message */
printf("\n%s\n\n", output);

The output as below:
Client read 80 bytes
Client read 80 bytes
Client read 8 bytes
Your messages:
1:From User1, 04/21/16 02:12 AM, MSG1
2:From User2, 04/21/16 02:162 AM, MSG2
3:From User2, 04/21/16 02:12 AM, MSG3
4:From User1, 04/21/16 02:12 AM6, MSG4

The expect output should be:
Client read 80 bytes
Client read 80 bytes
Client read 8 bytes
Your messages:
1:From User1, 04/21/16 02:12 AM, MSG1
2:From User2, 04/21/16 02:12 AM, MSG2
3:From User2, 04/21/16 02:12 AM, MSG3
4:From User1, 04/21/16 02:12 AM, MSG4

It seems that there is unexpected char('6') shown in buf[] in the second loop.
As I define the size of each time read() socket, so I want to loop read until the read amount is less than the limit_size, then output.
What should I do with the buf[] during the loop to avoid the unexpected chars?

A:

1- output is used uninitialized in
strcat(output, buf);

2- memset wants a pointer and buf is already (decays into) a pointer
memset(&buf, 0, sizeof(buf));

should be
memset(buf, 0, sizeof(buf));

3- If count == 80 then you have no space for the trailing NUL in your buffer, declare bufas char buf[81]; (or read 79 bytes) and don't forget to end your string with \0 after read()
buf[count] = '\0';

