C program to illustrate the concept of unions

C program to demonstrate unions. unions are like C structures, but every member occupies the same memory region. Read more about C Programming Language . /************************************************************ You can use all the programs on www.c-program-example.com* for personal and learning purposes. For permissions to use the* programs for commercial purposes,* contact [email protected]* To find more C programs, …

C Program to convert IP address to 32-bit long int

An IPv4 address is displayed as four decimal octets separated by dots (e.g., 192.168.1.1) but is stored internally as a single 32-bit unsigned integer. Converting between the dotted-decimal string and the integer form is a fundamental networking operation — inet_addr() in the POSIX socket API does exactly this. Understanding how to do it manually shows …

C program to find the size of a union.

A union in C is similar to a structure, but all its members share the same memory location. While a struct allocates separate space for each member, a union allocates space equal to its largest member, and every member overlaps that same block of memory. Only one member holds a valid value at any point …