0

我正在了解 Winsock 并正在查看页面中的代码: Winsock 教程 1

程序中有一行包含运算符 =*。谁能告诉我这是什么?我知道 a *= b 等价于 a = a * b。我在stackoverflow上读到=+是+=的过时形式。所以我尝试交换 * 和 = 使其成为 *=,但编译器给了我一个错误。如果有人告诉我这行代码的含义,我将不胜感激:

SockAddr.sin_addr.s_addr=*((unsigned long*)host->h_addr);
4

2 回答 2

5

这意味着取消引用某些内容并将其分配给 LHS。

SomeType LHS;
SomeType* Something = ....;
LHS = *(Something);

请参阅取消引用运算符

于 2013-01-25T17:57:18.187 回答
1

Operator =* existed in nascent versions of C language (as the original form of *= operator).

In C++ there's no such operator. =* is nothing else than = (assignment operator) followed by unary * (dereference operator). You can look up the meaning of = and unary * in your favorite C++ book.

于 2013-01-25T18:06:55.913 回答