Question
question 2 Prepare a text file with several lines of text. Write a C program that reads the text file name from the user via
question 2
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.
(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.
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