I have this function:
void receive_message(int sock, char buffer[]) {
int test = recv(sock, buffer, strlen(buffer), 0);
buffer[test] = '\0';
}
the third argument of the function recv() is not working. apparently i cannot use strlen() because the buffer don’t have a \0. sizeof() didn’t help me either. i’m wishing i can do this without passing a third argument to my function receive_message().
thank you.
You’re hoping in vain; C arrays don’t have that much structure. You need to pass the size yourself.