0% found this document useful (0 votes)
6 views4 pages

File Handling Questions.

Uploaded by

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

File Handling Questions.

Uploaded by

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

Register No: RTC2024BCS021

EXPT NO :

DATE : Read and Display File Content in C

Aim
To write a C program that reads data from a text file and displays it on the screen.

Algorithm
1. Start
2. Declare necessary variables, including a file pointer.
3. Open the text file in read mode (r) using fopen().
o If the file cannot be opened, display an error message and exit.
4. Read the contents of the file using fgetc() or fgets() in a loop.
5. Display the content on the screen as it is read.
6. Close the file using fclose().
7. End.

Solution Code
Register No: RTC2024BCS021

Input:

input.txt file:

Output:

Result:
Register No: RTC2024BCS021

EXPT NO :

DATE : Append Data from One File to


Another in C

Aim
To write a C program that reads data from one text file and appends it to another file.

Algorithm
1. Start
2. Declare necessary variables, including two file pointers.
3. Open the source file in read mode (r) and the destination file in append mode (a).
4. If either file cannot be opened, display an error message and exit.
5. Read the contents of the source file using a loop and append the data to the
destination file.
6. Close both files using fclose().
7. End.

Solution Code
Register No: RTC2024BCS021

Input files:

1.Source file:

2.Destination file:

Output:

Destination.txt file after appending data from source file

Result:

You might also like