C Macros

C Macros: A macro value in C replaces a part of a program with a value already defined by #define directive. Macros can be of four types: Object-like Macros: When a macro is simply replaced by a value, then it is called as Object like Macro. Syntax: #define macro_Name macro_Value Function-like Macros: When a macro … Read more

Categories C

C Preprocessor Directives

C Preprocessor Directives: The Preprocessor Directives are a part of C program which are executed before compilation, hence the name Preprocessor. These Preprocessor Directives are easily identified as they starts with hash # symbol. The preprocessors are also used to add macros in a C program. Some of the Preprocessor Directives are; #include #define #undef … Read more

Categories C

C ftell()

C ftell() function: To get the current file position, ftell() function is used in C. Syntax: ftell(FILE *stream) Example: #include <stdio.h> void main(){ FILE *f;   f = fopen("file.txt","w+"); fputs("Hello C..", f); fclose(f);   f = fopen("file.txt","r"); fseek(f, 0, SEEK_END);   int size = ftell(f); fclose(f); printf("Size of file.txt is: %d bytes", size); }#include <stdio.h> … Read more

Categories C

C rewind()

C rewind() function: To use stream many times, the rewind() function is used in C. This function sets the file pointer at the beginning of the stream. Syntax: rewind(FILE *stream) Example: #include <stdio.h> void main(){ FILE *f;   f = fopen("file.txt","w+"); fputs("Hello C..", f); fclose(f);   char arr[100]; f = fopen("file.txt","r"); printf("%s",fgets(arr,65,f));   rewind(f); f … Read more

Categories C

C fseek()

C fseek() function: To write data into a file at a desired location, fseek() function is used in C. This function sets the file pointer in C to a specified offset. C fseek() function Constants: Constants used in the fseek() function are: SEEK_SET SEEK_CUR SEEK_END Syntax: fseek(FILE *stream, long int offset, int whence) Example: #include … Read more

Categories C

C fputs() fgets()

C Write File: File handling simply means to open a file and to process it according to the required tasks. Writing data in a file is one of the common feature of file handling. In C, there are various modes that facilitates different ways and features of writing data into a file, including: w, r+, … Read more

Categories C

C fputc() fgetc()

C Write File: File handling simply means to open a file and to process it according to the required tasks. Writing data in a file is one of the common feature of file handling. In C, there are various modes that facilitates different ways and features of writing data into a file, including: w, r+, … Read more

Categories C

C fprintf() fscanf()

File handling simply means to open a file and to process it according to the required tasks. Writing data in a file is one of the common feature of file handling. In C, there are various modes that facilitates different ways and features of writing data into a file, including: w, r+, w+, a+, wb, … Read more

Categories C

C File Handling

C File Handling: File handling simply means to open a file and to process it according to the required tasks. C facilitates several functions to create, read, write, append, delete and close files. ❏     Open File: To open a file in C, fopen() function is used. ❏     Close File: To close a file in C, … Read more

Categories C

C Nested Structure

C Nested structure: A C Nested Structure can be defined in two ways: By separate structure: Defining a Nested Structure by separate structure simply means to use a structure inside another structure as a member of that structure. In this way, a single structure can be used in many structures. Example 1: #include<stdio.h> #include <string.h> … Read more

Categories C