C Language Archive
Pointer to function: It is also possible to create pointers to Derived data types such as function, array, string….. To execute block of instructions, OS allocates the memory in stack area is called “FRAME”. Every …
Unions union is a keyword. Unions are used to create user defined data types. Unions working like structure. Syntax of structure and union : Note: The only difference between structure and union is, structure allocates …
Dynamic Memory Allocation In C programming language, we allocate memory in 2 ways Static memory – Fixed in size Dynamic memory – Size varies Static memory is allocated to ordinary variables as follows. stdlib.h: Pre-defined …
malloc(): Allocate memory to structures dynamically. Allocated block address will be assigned to pointer type variable. The prototype is: Why malloc() function returns void* type? Malloc() function can allocate memory to different types of structure …
Calloc(): It is used to allocate memory to arrays dynamically. It is belongs to stdlib.h header file. The prototype is: void* calloc(size_t n, size_t size); After memory allocation, all the locations initializes with default values. …
realloc : Using malloc function, we allocate memory for structure variables. Mostly data structure algorithms implementation like linked lists, trees and graphs uses struture data type to create nodes. Prototype: void* realloc(void* ptr, size_t size); …
free() : The memory which has allocated dynamically must be released explicitly using free function. Function prototype is: void free(void* ptr); Using free() funtion , we can de-allocate the memory of any type of pointer.
Files In C: stdio.h header file is providing variables and function to work with files. File is a physical storage area. File is a collection of bytes. We can store alphabets, digits and symbols into …
fopen(): A pre-defined function that opens a file in specified mode. Return type of fopen() function is FILE* type. On success, it opens and returns the pointer to file. On failure, it returns NULL pointer. …
Reading File character by character: fgetc() is a pre-defined function belongs to stdio.h fgetc() function read the input file character by character. On success, it reads the character and returns ASCII value of that character …