What is a union?

The union is a user-defined data type that allows storing multiple types of data in a single unit. However, it doesn’t occupy the sum of the memory of all members. It holds the memory of the largest member only. In union, we can access only one variable at a time as it allocates one common … Read more

What is the structure?

The structure is a user-defined data type that allows storing multiple types of data in a single unit. It occupies the sum of the memory of all members. The structure members can be accessed only through structure variables. Structure variables accessing the same structure but the memory allocated for each variable will be different. In … Read more

What functions are used for dynamic memory allocation in C language?

malloc() The malloc() function is used to allocate the memory during the execution of the program. It does not initialize the memory but carries the garbage value. It returns a null pointer if it could not be able to allocate the requested space. Syntax ptr = (cast-type*) malloc(byte-size) // allocating the memory using malloc() function. … Read more

What is dynamic memory allocation?

In case of dynamic memory allocation, memory is allocated at runtime and memory can be increased while executing the program. It is used in the linked list. The malloc() or calloc() function is required to allocate the memory at the runtime. An allocation or deallocation of memory is done at the execution time of a … Read more

What is static memory allocation?

In case of static memory allocation, memory is allocated at compile time, and memory can’t be increased while executing the program. It is used in the array. The lifetime of a variable in static memory is the lifetime of a program. The static memory is allocated using static keyword. The static memory is implemented using … Read more