NULL Pointers in C Programming

A pointer that is assigned NULL is called a null pointer. We must initialize NULL pointer during variable declaration. A null pointer refers to pointer variable that does not point to a valid address. Generally NULL pointer is used when you do not have an exact address to be assigned. #include int main () { int *ptr … Read more

Multi-dimensional Array in C Programming

C programming language also support multidimensional arrays. Syntax of multidimensional array declaration: Data_type    array_name[size1][size2]…[sizeN]; For example, if we want to creates a three dimensional integer array − int  num[5][10][4]; Two-dimensional Arrays The simplest form of multidimensional array is the two-dimensional array. if we want to declare a two dimensional integer array of size [x][y] ( … Read more

Pointer to Pointer in C Programming

In  C language, a pointer is an address. Normally, a pointer variable contains the address of a another variable.  A pointer to a pointer is a chain of pointers.  Or Pointer to pointer means one pointer variable holds the address of another pointer variable. #include int main() { int a=4; int *b, **c; b = … Read more

Pointers in C Programming

In    programming, variable is used to hole the value & this variable stored in a memory.  Each variable has a address to identify where these variables actually stored in a memory.     In a C programming language, pointer is a variable which can hold the address of another variable.   Accessing Address of Variable In … Read more

Recursion in C Programming

In C programming language, a function that calls itself is known as a recursive function. And, this technique is called as recursion.  Recursive functions are very useful to solve many problems such as  Towers of Hanoi (TOH), Inorder/Preorder/Postorder Tree Traversals, DFS of Graph, etc. How recursion works? void recurse() { … .. … recurse(); … .. … … Read more

Union in C Programming

In C programming language, union is a special user defined data type that allows to store different data types in the same memory location. “union”  uses the same memory location for multiple-purpose.  Or In a union data type, single variable, i.e., same memory location, can be used to store multiple types of data. In c programming … Read more

Structures in C Programming

There are various types of data type such as int, char float etc. For example:  int  i;      here variable i can store only data of integer type            char c;   here variable c can store only data of character type           float  f; here variable f can store only data of floting-point type … Read more

File handling programs in C Programming

Example : Write a C program to copy the contents of one file to another file. #include #include // For exit() int main() { FILE *fp1, *fp2; // Declare two file pointer fp1 & fp2 char filename[50], c; printf(“Enter the filename to open for reading “); scanf(“%s”, filename); fp1 = fopen(filename, “r”); // Open file for … Read more

Writing to a File in C Programming

To write on a file there are following  function available:  Function fputc() : function fputc() write individual characters at a time to the file. The syntax of this function is – Syntax :                int  fputc( int c,  FILE *fp ); Function fputc()  returns the written character written on success and  if there is an error it will return … Read more