Passing function as an argument.
Hi!
There are two functions in my code:
Code:
void *memcpy(void *dest, const void *src, size_t n);
in_addr_t inet_addr(const char *cp);
I want to set IP address to an 4 element array in structure:
Code:
memcpy(arp->src_pr_addr, inet_addr("127.0.0.1"), 4);
But then I get an error:
Quote:
arp_request.c:53: warning: passing arg 2 of `memcpy' makes pointer from integer without a cast
But when I define another variable and pass its address everything works:
Code:
long ip = inet_addr("127.0.0.1");
memcpy(arp->src_pr_addr, &ip, 4);
How can I pass function directly to memcpy(); functions second argument? Do I need some casting? Thank you!