Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Prepare a text file with several lines of text. Write a C program that reads the text file name from the user via the keyboard.

Prepare a text file with several lines of text. Write a C program that reads the text file name from the user via the keyboard. The C program should also read a file name that is used to store the output. Open the given text file and read lines stored in that text file. For each line, change the lowercase letters (a to z) to upper case letters (A to Z) and change the uppercase letters to lowercase letters. Write changed lines to the given output file.

Hint: (i) You can assume the maximal length of each line in the file is 1024. (ii) When you get a file name str from the user, you can use fopen(str, r) to open that file. (iii) You can use whether the return value of fgets() is NULL to juedge whether we meet the end-of-file (EOF) mark. For example, fgets(str, 1024, inFile) == NULL when the file stream inFile meets the EOF mark. (iv) The string you get from fgets() already have a at the end of the string. Therefore, when you print the string to the file, you do not need to add a after it.

The following is the sample content of a text file input.txt.

image text in transcribed

The following is the sample run of the program (The blue font is input by the user). image text in transcribed

After the program finishes, the content of output.txt file is image text in transcribed

(i) Please upload the source code file as the attachment. (ii) Please upload the input file and output file of your sample run as the attachments.

This is the first line. Next line is here. Finish the input by a enter key. Please enter the input file name: input.txt Please enter the output file name: output.txt Done! THIS IS THE FIRST LINE. NEXT LINE IS HERE. FINISH THE INPUT BY A ENTER KEY

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Administration The Complete Guide To Dba Practices And Procedures

Authors: Craig S. Mullins

2nd Edition

0321822943, 978-0321822949

More Books

Students also viewed these Databases questions