Computer Science Questions and Answers: C-Programming (File) Part - 13

1) What is a file?
A file is a collection of data that is available in permanent storage.

2) Write the syntax for file declaration.
syntax: FILE *filepointer;
Ex: FILE *fp;

3) What are modes in file?
Mode tells about the types operations like read,write or append that can be performed on a file that is being opened.

4) Write the syntax to open a file.
syntax: filepointer=fopen(FILENAME,MODE);
Ex: fp=fopen(“in.dat”,r);

5) What is the significance of fclose() function?
This function closes a file that has been opened for an operation. Syntax:
fclose(filepointer);
Ex: fclose(fp);