c - 从类型 ‘struct in_addr’ 分配给类型 'unsigned int' 时不兼容的类型

标签 c linux ip-address ipv4

我使用Linux进行编译。在 struct ip (对于 IPv4)中,当我尝试将值指定为 ip1.ip_dst = 0xffffffff; 时,出现以下错误:

error: incompatible types when assigning to type ‘struct in_addr’ from type 'unsigned int' ip.ip_dst = 0xffffffff;`

我应该为具有 struct in_addr 数据类型的变量赋予什么值?我该如何解决这个错误?

最佳答案

in_addr 是一个具有单个 unsigned long 成员的结构:

struct in_addr ip_dest;
ip_dest.s_addr = 0xffffffffL;

关于c - 从类型 ‘struct in_addr’ 分配给类型 'unsigned int' 时不兼容的类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34367459/

相关文章:

mysql - makefile 错误 ----> make : *** No rule to make target `mysql.h'

c - getenv 的标准 C 用法和安全实践

php - 有人可以将 IP 地址欺骗到任何号码吗?

ios - 尝试在 iPhone 上快速获取 IP 地址时出错

直接从 typedef 结构定义创建指针

android - Android 有办法在 adb 中显示进程优先级吗?

c++ - 在 C++ 中使用 system();不起作用

php - 如何从 PHP 访问第二个磁盘驱动器?

c++ - 为什么在删除适配器的默认 IP 时 DeleteIPAddress 会失败?

c - 多行输入