Discuss / Python / 是不是写错了?

是不是写错了?

Topic source

绊倒铁盒

#1 Created at ... [Delete] [Delete and Lock User]

而在C语言中,我们可以很方便地用struct、union来处理字节,以及字节和int,float的转换

上句中提到在C语言中使用struct处理数据的转换,struct是结构体的意思吧,可以用来表示对象.至于数据转换有这个功能吗?

廖雪峰

#2 Created at ... [Delete] [Delete and Lock User]
typedef struct
{
    char n1;
    char n2;
    char n3;
    char n4;
} IP;

typedef union
{
    IP ip;
    int addr;
} IP_ADDR;

  • 1

Reply