看到一个程序段里面有 (void *)&sin,不知道是什么意思,是函数吗?
if(connect(csock,(void *)&sin,sizeof(sin)))
errexit("has't connect to the server !:%s\n",strerror(errno));
else
printf("has connect to the server!\n");
...全文
51830打赏收藏
(void *)&sin是什么呢
看到一个程序段里面有 (void *)&sin,不知道是什么意思,是函数吗? if(connect(csock,(void *)&sin,sizeof(sin))) errexit("has't connect to the server !:%s\n",strerror(errno)); else printf("has connect to the server!\n");
个人看法,楼上的兄弟们都说强制转换,但是这个表面谁看不是强制转换嘛^_^,我想楼主主要想知道的是为什么要将地址强制转换void *,这个就要看connect这个函数实现中拿sin做了什么,将地址转成void后,就可以通过这个地址访问自己想访问的数据,我说得笼统,举个例子楼主就知道了
struct a
{
int b;
int c;
}*aa;