0% found this document useful (0 votes)
4 views

Tutorial-9_File Handling

This document is a tutorial for the Object Oriented Programming course at Jaypee University, focusing on file handling in C++. It includes questions and programming tasks related to file operations, such as creating, reading, merging, and manipulating files. The tutorial aims to enhance understanding of file handling concepts and practical applications in programming.

Uploaded by

om gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Tutorial-9_File Handling

This document is a tutorial for the Object Oriented Programming course at Jaypee University, focusing on file handling in C++. It includes questions and programming tasks related to file operations, such as creating, reading, merging, and manipulating files. The tutorial aims to enhance understanding of file handling concepts and practical applications in programming.

Uploaded by

om gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Jaypee University of Engineering and Technology, Guna

Department of Computer Science and Engineering


Object Oriented Programming (CS102)
Tutorial – 9
(File Handling)
1. What is the difference between opening a file with a constructor function and opening a file
with open() function? When is one method preferred over the other?
2. Write the statemens for following situations:
i. Create an object called fob for writing, and associate it with a file name DATA.
ii. Create an object fin for reading a file “my_file.txt”.
iii. Create a file stream that can open a binary file “file.dat” in read and write mode.
3. How many file objects would you need to create to manage the following situations?
(a) To process four files sequentially.
(b) To merge two sorted files into a third file. Explain.
4. Write a program that creates a text file “TEXT.txt”on the disk. Write text on this file. Read this
file and display the following information on the screen in two columns:
 Number of lines
 Number of words
 Number of characters
Strings should be left-justified and numbers should be right-justified in a suitable field width.
5. Two file named ‘Source1’ and ‘Source2’ contain sorted list of integers. Write a program that
reads the contents of both the files and stores the merged list in sorted form in a new file
named ‘Target’.
6. Write a program in C++ to read the file and store the lines into an array.

7. Write a program in C++ to copy a file in another name.

8. Write a program in C++ to merge two files and write it in a new file.

9. Write a program in C++ to encrypt a text file.

10. Write statements using seekg() to achieve the following:


(a) To move the pointer by 40 positions forward from current position.
(b) To go to the end after an operation is over.
(c) To go backward by 35 bytes from the end.
(d) To go to byte number 20 in the file.

You might also like