Question
Create test.file and save it into your directory ~/Dowloads on Linux server. Then, write a program in C, which does the following tasks: 1. Create,
Create test.file and save it into your directory ~/Dowloads on Linux server.
Then, write a program in C, which does the following tasks:
1. Create, in your current directory, a new file named XYZ, and copy the file ~/Dowloads/test.file into that file in the following way:
a. read the next 150 characters from test.file,
b. write characters from a. immediately in XYZ.
c. write characters ABC into file XYZ
Steps a., b. and c. are repeated until the end of file test.file. Note that the last read from test.file may not have 150 characters. At the end, display a number of characters read from test.file and a number of characters written into XYZ.
2. Create, in your current directory, two new files named XXX and WWW, and copy the file XYZ into those two files in the following way:
a. read the next 120 characters from XYZ, and among characters read replace each character i with character 8 and write all 120 characters in XXX,
b. read the next 100 characters from XYZ, and among characters read replace each character m with characters B and then writes all characters in WWW.
Steps a. and b. are repeated until the end of file XYZ. Note that the last read may not have 120 or 100 characters.
At the end, display a number of characters written in XXX.txt and in WWW.
Delete file XYZ;
3. Write in XXX the following characters: 12345678abcdefgh starting at location 1000. The old characters in those positions are overwritten;
4. Append file WWW (i.e. write at the end of the file) with characters of your name. This will enlarge the file by some number of characters;
5. Insert into file WWW, starting after location 500, following characters: 1111abcdefghijklmnopQRSTUVWXYZ. This will enlarge file size by 30;
6. Create a new file named ZZZ and copy XXX into ZZZ. Copying should be done by reading 300 characters at time from file XXX and immediate writing them into file ZZZ.txt. Note that the last read from XXX may not have 300 characters.
7. Append file ZZZ with file WWW, but by writing it in reverse order. At the end, display a number of characters written into ZZZ.
8. Read ZZZ (80 characters at a time) and display every 100th set of 80 characters read. Delete files XXX, WWW and ZZZ.txt.
Please comment your program clearly indicating each step above.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started