Why do we need C Unions?

Unions are often used to convert between the binary representations of integers and floats: union { int i; float f; } u; // Convert floating-point bits to integer: u.f = 3.14159f; printf(“As integer: %08x\n”, u.i); Although this is technically undefined behavior according to the C standard (you’re only supposed to read the field which was … Read more

Purpose of Unions in C and C++

The purpose of unions is rather obvious, but for some reason people miss it quite often. The purpose of union is to save memory by using the same memory region for storing different objects at different times. That’s it. It is like a room in a hotel. Different people live in it for non-overlapping periods … Read more

Difference between a Structure and a Union

With a union, you’re only supposed to use one of the elements, because they’re all stored at the same spot. This makes it useful when you want to store something that could be one of several types. A struct, on the other hand, has a separate memory location for each of its elements and they … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)