help with char pointer array in C

i have an array like

    #define NUM 8
    ....
    new_socket_fd = accept(socket_fd, (struct sockaddr *) &cli_addr, &client_length);
    char *items[NUM] = {"one", "two", "three", "four", "five", "six", "seven", "eight"};
    char *item_name_length[NUM] = {"3", "3", "5", "4", "4", "3", "5", "5"};
    send_items(items, item_name_length, &NUM , &new_socket_fd);
void send_items(char *items[], char *item_name_length[], int *length, int *new_socket_fd) {
    int i, bytes;
    for(i = 0; i<*length; i++) {
        bytes = write(*new_socket_fd,items,atoi(item_name_length));
        if (bytes < 0) error("ERROR writing to socket");
    }
}

and i get this error on the line where i call the function

error: lvalue required as unary �&� operand

whats wrong?

NUM is not a variable. #define's do literal text substition at compile-time, which ends up trying to do send_items(items, item_name_length, &8 , &new_socket_fd); , which of course won't work.

1 Like