The C statements that would do this are:
#include<stdio.h>
main()
{
FILE *ptr1, *ptr2;
ptr1 = fopen ("a.dat", "r");
ptr2 = fopen ("b.dat", "w");
----
----
}
The function fopen() opens a file in the appropriate access mode.
When a file is opened, certain information regarding that file automatically gets stored in different variables. These variables are collectively classified as the data type FILE. fopen() returns a pointer to this FILE type data. Hence, the following declaration is required for defining the two pointers:
FILE *ptr1, *ptr2;
The definition of the data type FILE is provided in a standard header file called stdio.h, which is therefore included in this program.
The parameters r and w in the fopen() statements indicate the mode of access to these files.
C allows a number of modes in which a file can be opened.
1 comments:
This blog is a great source of information which is very useful for me.
ICC T20 World Cup Opening Ceremony Date, Starting Time & Venue
England Team Captain T20 World Cup 2016
Cricket world cup live on hotstar
Post a Comment