Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

wats wrong with this £")(*$ thing

  • 05-02-2002 8:06pm
    #1
    Closed Accounts Posts: 8,478 ✭✭✭


    #include<sys/types.h>
    #include<netdb.h>
    #include<sys/socket.h>
    #include<stdio.h>
    #include<sys/un.h>
    #include<unistd.h>


    int main()
    {
    int server_sockfd, client_sockfd;
    int server_len, client_len;
    struct sockaddr_un server_address;
    struct sockaddr_un client_address;
    FILE *fp;
    char buffer[1000];

    unlink("server_socket");
    server_sockfd = socket(AF_UNIX, SOCK_STREAM, 0);


    //Name the socket
    server_address.sun_family = AF_UNIX;
    strcpy(server_address.sun_path, "server_socket");
    server_len = sizeof(server_address);
    bind(server_sockfd, (struct sockaddr *)&server_address, server_len);

    listen(server_sockfd, 5);
    while(1)
    {


    printf("Server writing \n");

    client_sockfd = accept(server_sockfd, (struct sockaddr *)&client_address, &client_len);
    fp = fopen("sender.txt", "r");

    if(fp = NULL)
    {
    printf("Error : Can not open File");
    }
    else
    {
    while(!feof(fp))
    {
    fread (*buffer, 1, 1000, fp);
    }
    fclose(fp);
    read(client_sockfd, &buffer, 1000);
    printf("Server:: File from client = %c \n",buffer);
    printf("Server:: File to client = %c \n",buffer);
    write(client_sockfd, &buffer, 1000);
    close(client_sockfd);
    }//End of while
    }//End of main
    }

    i get one error, passing arg 1 of fread makes pointer from integer without a cast.

    Cant figure it out, wat the fupp is wrong with it !!


Comments

  • Registered Users, Registered Users 2 Posts: 3,744 ✭✭✭deRanged


    that message means you're passing a basic type in instead
    of a pointer.

    fread expects a void* for its first param,
    you're passing in *buffer,
    but buffer is effectively a char *,
    so after you dereference it you pass in a char.
    that's why you're getting that message.

    just pass in buffer.

    did that make any sense?


Advertisement