PDA

View Full Version : C compile error


Arachno331
11-15-2007, 05:58 PM
Someone please help me solve this error!

socket.c: In function ‘Do_accept_connections’:
socket.c:252: warning: passing argument 1 of ‘strncpy’ from incompatible pointer type


This is line 252:

/*
errno = 0;
host_info = gethostbyaddr((char *)&client_ptr->address.sin_addr,
sizeof(client_ptr->address.sin_addr), AF_INET);
theError = errno;
*/

How would I fix this?

Dunna
11-15-2007, 06:10 PM
That isn't line 252. Line 252 contains a strncpy. Besides, that code is commented out. Post the actual code that contains strncpy and I will be able to help you. Besides that, that message is not an error- it's just a warning. So your program should compile anyway.

Arachno331
11-15-2007, 07:35 PM
/* copy over the hostname */
strncpy(&client_ptr->IP, host_info->h_name, SZ_FROM - 1);
client_ptr->IP[SZ_FROM - 1] = '\0';

Arachno331
11-15-2007, 10:15 PM
Solved.

Took out the Ampersand.