0
6.8kviews
What is file? Explain various file handling operations in C.

Mumbai University > COMPS > Sem 3 > Data Structures

Marks: 5 M

Year: May 2015

1 Answer
0
237views
  • A file is a collection of records where each record may contain different fields.
  • These records may be of same size or different size.
  • If the file contains records of various sizes, then it is called variable length records.
  • The basic file operations include: Creation, Opening, Searching, Inserting, Deleting, and Updating.
  • The various file handling operations in c are:

    a. fopen(): This command is used to open a particular file. The Syntax for it is:

    File *fptr;

    Fptr=fopen(“filename”,”mode”);

    Here fptr is a pointer to the file

    Here filename is name of file and mode can be the mode of opening like

    write(w), read(r), append(a).

    b. fclose(fptr): This command is used to close a file.

    c. getc (): Used to read from the file.(SingleCharacter)

    d. putc(): Used to write into the file. (SingleCharacter)

    e. fprinf(): write multiple data to file.

    f. fscanf(): read multiple data from file.

    g. fputs(): write a string into file.

    h. fgets(): read string from file.

    i. ftell(fptr): returns the current position of file pointer.

Please log in to add an answer.