Skip to main content

Featured Post

How to use Tabs in ASP.NET CORE

I want to show Components in a tabs , so first of all create few components. In this project we have three components, First View Component  public class AllViewComponent : ViewComponent     {         private readonly UserManager<ApplicationUser> _userManager;         public AllViewComponent(UserManager<ApplicationUser> userManager)         {             _userManager = userManager;         }         public async Task<IViewComponentResult> InvokeAsync()         {             List<StudentViewModel> allUsers = new List<StudentViewModel>();             var items = await _userManager.Users.ToListAsync();             foreach (var item in items)             {                 allUsers.Add(new StudentViewModel {Id=item.Id, EnrollmentNo = item.EnrollmentNo, FatherName = item.FatherName, Name = item.Name, Age = item.Age, Birthdate = item.Birthdate, Address = item.Address, Gender = item.Gender, Email = item.Email });             }            

File Pointer in C

In order to use files it is mandatory to learn the file Input / Output operations. Learning of these is nothing but to understand the functions to write data into a file, to read data from a file, etc. For at any of such operations the file must be opened. The file opening operation is done through a pointer variable called as file pointer. So, file pointer is nothing but a variable which is declared and then I to any required physical file. All the I/O operations are done to physical file through the logical file.

A File Pointer is a special type of pointer variable of the type FILE that is used to store the address of a physical file.

FILE I/O is almost identical to the console and terminal I/O operations. The pnntf() function is used to display the data on the screen. And in file handling we use fprintf() to write the data into the file. We use scanf() function to read the data from the keyboard. And in file handling we use fscanf() to read the data from the file. This is called file manipulation.

The major difference between manipulation of file and terminal I/O is that the terminal I/O is standard no need to specify anything but it is necessary to specify files to be used in the programs where file I/O are performed. It is possible have many files on the disk. If you wish to use a file or files in the programs, then you must specify which file or files you wish to use. Specification of the file that is to be used is referred as opening a file.
At the time of opening the file it is also compulsory to specify the type of operation to be performed i.e. Read from the file, Write to the file, or both. This specification is done through the file opening mode. When different files are used in the program, it is required to specify a particular file for reading or writing. It can be done using a variable called a FILE pointer.

Every file you open has its own FILE pointer variable. When you wish to write to a fiie you specify the file by using its file pointer variable. The file pointer declared using FILE data type is called as logical file. The data is not stored permanently on the secondary storage with this name. It is stored with other file name which is called as physical file name. The logical file is linked with this physical file name. The read/write operations are done on logical file in the program which is indirectly transferred from or to the physical file. The linking of logical file with physical file is done through fopen() function. The FILE pointer variables can be declared as follows:

FILE *fP1, *fp2, *fp3;

The variables fpl, fp2, fp3 are the pointer variables of the type FILE or simply file pointers. They can store the address of any physical file.

Any name can be used as file pointer but must be a valid variable or identifier name of C language. The rules of standard data type identifiers apply to these variables also. The declared FILE Pointer variable may hold address of any physical file but only one at a time. So, at a given point of time logically a logical file points to one and only one physical file. The read / write operactions performed on the file pointer indirectly directed to physical file. At the time of opening file the file pointed by file pointer variable is mentioned along with the type of operation. The opened file is closed when the operation is finished or whenever a new file is to be attached. We will discuss file opening and closing in more details in the next article.

Comments

Popular Post

Polynomial representation using Linked List for Data Structure in 'C'

Polynomial representation using Linked List The linked list can be used to represent a polynomial of any degree. Simply the information field is changed according to the number of variables used in the polynomial. If a single variable is used in the polynomial the information field of the node contains two parts: one for coefficient of variable and the other for degree of variable. Let us consider an example to represent a polynomial using linked list as follows: Polynomial:      3x 3 -4x 2 +2x-9 Linked List: In the above linked list, the external pointer ‘ROOT’ point to the first node of the linked list. The first node of the linked list contains the information about the variable with the highest degree. The first node points to the next node with next lowest degree of the variable. Representation of a polynomial using the linked list is beneficial when the operations on the polynomial like addition and subtractions are performed. The resulting polynomial can also

How to use Tabs in ASP.NET CORE

I want to show Components in a tabs , so first of all create few components. In this project we have three components, First View Component  public class AllViewComponent : ViewComponent     {         private readonly UserManager<ApplicationUser> _userManager;         public AllViewComponent(UserManager<ApplicationUser> userManager)         {             _userManager = userManager;         }         public async Task<IViewComponentResult> InvokeAsync()         {             List<StudentViewModel> allUsers = new List<StudentViewModel>();             var items = await _userManager.Users.ToListAsync();             foreach (var item in items)             {                 allUsers.Add(new StudentViewModel {Id=item.Id, EnrollmentNo = item.EnrollmentNo, FatherName = item.FatherName, Name = item.Name, Age = item.Age, Birthdate = item.Birthdate, Address = item.Address, Gender = item.Gender, Email = item.Email });             }            

Memory representation of Linked List Data Structures in C Language

                                 Memory representation of Linked List              In memory the linked list is stored in scattered cells (locations).The memory for each node is allocated dynamically means as and when required. So the Linked List can increase as per the user wish and the size is not fixed, it can vary.                Suppose first node of linked list is allocated with an address 1008. Its graphical representation looks like the figure shown below:       Suppose next node is allocated at an address 506, so the list becomes,   Suppose next node is allocated with an address with an address 10,s the list become, The other way to represent the linked list is as shown below:  In the above representation the data stored in the linked list is “INDIA”, the information part of each node contains one character. The external pointer root points to first node’s address 1005. The link part of the node containing information I contains 1007, the address of