Why use char* to handle a union's address?

1965 views c
8

union a {
    struct a_header a_hdr;
    struct b        b_hdr;
};

bzero((char*)(&(&a->a_hdr)[1]), sizeof(struct b) - sizeof(struct a_header));

What does this call do? Where does (char*)(&(&a->a_hdr)[1]) point to?

answered question

Older, pre-ANSI C used char * for all memory addresses, where char was always a byte.

1 Answer

10

Well it's casting it to a char * so it can add a single byte to it and zero some memory starting at the address of the instance + that 1 byte.

You'd have to ask the author why they want to do that.

posted this

Have an answer?

JD

Please login first before posting an answer.