Category: C

Pointer to Pointer in C

Pointer to Pointer in C (Double pointer) As we know that, a pointer is used to store the address of a variable in C. Pointer reduces the access time of a variable. However, In C, we can also define a pointer to store the address of another pointer. Such pointer is known as a double […]

C Pointers

C Pointers The pointer in C language is a variable that stores the address of another variable. This variable can be of type int, char, array, function, or any other pointer. The size of the pointer depends on the architecture. However, in 32-bit architecture the size of a pointer is 2 byte. Consider the following […]

Recursion in C

Recursion in C Recursion is the process that comes into existence when a function calls a copy of itself to work on a smaller problem. Any function which calls itself is called a recursive function, and such function calls are called recursive calls. Recursion involves several numbers of recursive calls. However, it is important to […]

Call by value and Call by reference in C

Call by value and Call by reference in C: Please find below details about Call by value and Call by reference in C – There are two methods to pass the data into the function in C language, i.e., call by value and call by reference. Let’s understand call by value and call by reference in c language […]

File Handling in C

File Handling in C: In programming, we may require some specific input data to be generated several numbers of times. Sometimes, it is not enough to only display the data on the console. The data to be displayed may be very large, and only a limited amount of data can be displayed on the console, […]

C fprintf() and fscanf()

C fprintf() and fscanf() Please find below explanation about C fprintf() and fscanf() with examples – Writing File : fprintf() function The fprintf() function is used to write set of characters into file. It sends formatted output to a stream. Syntax: int fprintf(FILE *stream, const char *format [, argument, …]) Example: #include <stdio.h> main(){ FILE *fp; fp = fopen(“file.txt”, “w”);//opening file fprintf(fp, “Hello file by fprintf…\n”);//writing data into file fclose(fp);//closing file } Reading File : fscanf() function […]

C fputc() and fgetc()

C fputc() and fgetc(): Please find below explanation about C fputc() and fgetc() with examples- Writing File : fputc() function The fputc() function is used to write a single character into file. It outputs a character to a stream. Syntax: int fputc(int c, FILE *stream) Example: #include <stdio.h> main(){ FILE *fp; fp = fopen(“file1.txt”, “w”);//opening file fputc(‘a’,fp);//writing single character into file fclose(fp);//closing file } file1.txt a Reading File : fgetc() […]

C fputs() and fgets()

C fputs() and fgets(): The fputs() and fgets() in C programming are used to write and read string from stream. Let’s see examples of writing and reading file using fgets() and fgets() functions. Writing File : fputs() function The fputs() function writes a line of characters into file. It outputs string to a stream. Syntax: […]

C fseek() function

C fseek() function The fseek() function is used to set the file pointer to the specified offset. It is used to write data into file at desired location. Syntax: int fseek(FILE *stream, long int offset, int whence) There are 3 constants used in the fseek() function for whence: SEEK_SET, SEEK_CUR and SEEK_END. Example: #include <stdio.h> void main(){ FILE *fp; fp = fopen(“myfile.txt”,“w+”); fputs(“This is CloudsNClear”, fp); fseek( fp, 7, SEEK_SET ); fputs(“Rohit […]

Constant Pointers in C

Constant Pointers in C: A constant pointer in C cannot change the address of the variable to which it is pointing, i.e., the address will remain constant. Therefore, we can say that if a constant pointer is pointing to some variable, then it cannot point to any other variable. Syntax of Constant Pointer <type of pointer> *const <name of pointer>; Declaration […]