Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

gcccompilerleavingblankspacesinerrors

Here is the code in my testclient.c file. I know exactly what the error occurring is. My question is regarding the output of the compiler.

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>

int main(int argc, char * argv[]){
    int network_socket;
    network_socket = socket(AF_INET,SOCK_STREAM,0);

    struct sockaddr_in server_address;
    server_address.sin_family = AF_INET;
    server_address.sin_port = htons(37924);
    server_address.sin_addr = INADDR_ANY;

    int connection_status = connect(network_socket, (struct sockaddr *)&server_address,sizeof(server_address));

    if(connection_status == -1){
            printf("\n\nError: couldn't connect to remote socket\n\n");
    }

    char server_response[256];
    recv(network_socket,&server_response,sizeof(server_response),0);

    printf("Server sent data: %s",server_response);

    close(sock);

    return 0;
} 

I am compiling with:

gcc testclient.c -o testclient

Error message

In function '      ' :
error: incompatible types when assigning to type '     ' from type '      ' 
error: '       ' undeclared (first use in this function)

Question:

Whenever I compile my code, I am getting these blank spaces in the error message. Does anyone know why this might be happening?

Why is gcc not able to identify the types and functions?

Comments