MULTIPLE FILE COMPILATION:
Multiple file compilation in C allows you to divide your program into multiple source files and compile them separately before linking them together to create the final executable file. This can help to make your code more modular and easier to manage.
➔
Create separate source
files: Divide your program into separate source files, each containing a
different set of functions or modules.
➔
Create header files: Create
header files for each source file that contains declarations for the functions
and data structures used in that source file.
Compile the source files: Compile each source file separately using a C compiler. This will produce object files (.o files) for each source file.
HEADER
FILES:
Header files in C are
files that contain function prototypes, macro definitions, and other
declarations that are used by other source files in a program. Header files
typically have a .h extension and are included in source files using the
#include directive.
DYNAMIC MEMORY
MANAGEMENT:
Dynamic memory
management in C allows you to allocate and deallocate memory at runtime, as
opposed to static memory allocation where memory is allocated at compile time.
void
* calloc(int num,int size);
Clear allocation -> no garbage value
Allocates array number of elements of
which size in bytes will be size.
The function releases a block of memory by specified address.
void* malloc(size, t_size);
Memory
allocation
This
function allocates an array of new bytes and leaves them uninitialized.
void*
realloc(new size)
Reallocation
This is used to increase/expand the
memory which has been already given.
Example 01:
Example 02:
Example 03:
0 Comments