帮帮忙,我错在哪里?(已经两天了!!!)(100分)

  • 主题发起人 主题发起人 yanyuwuhen
  • 开始时间 开始时间
Y

yanyuwuhen

Unregistered / Unconfirmed
GUEST, unregistred user!
addrS:sockaddr_in;
....
Re:=recvfrom(fd,BufRecv^,1024,0,addrS,Pinteger(sizeof(addrS)));
....

[Error]Types of actual and formal var parameters must be identical
 
var
BufRecv:array[0..1023]of Char;
Len:Integer;
......
Len:=sizeof(addrS);
Re:=recvfrom(fd,BufRecv,1024,0,addrS,Len);

详见: http://www.delphibbs.com/delphibbs/dispq.asp?lid=263140
 
万分感谢!这个错误我自己是怎么也看不出来的!
但我很奇怪,为什么会错呢?(我试过,不用Pinteger也是错)
sizeof()本身求得的就是整型啊,为什么不能直接这么写呢!
 
int recvfrom (
SOCKET s,
char FAR* buf,
int len,
int flags,
struct sockaddr FAR* from,
int FAR* fromlen
);

Parameters

s
[in] A descriptor identifying a bound socket.

buf
[out] A buffer for the incoming data.

len
[in] The length of buf.

flags
[in] Specifies the way in which the call is made.

from
[out] An optional pointer to a buffer which will hold the source address upon return.

fromlen
[in/out] An optional pointer to the size of the from buffer.
~~~~~~~~~ 注意:此参数出了输入以外,还要输出,因此不能用常量代替
 
谢谢creation-zy的热心指点!
 
后退
顶部