Question
I need to write a program that takes input from a file that has characters. The file that I mentioned has a single character on
I need to write a program that takes input from a file that has characters. The file that I mentioned has a single character on each of its lines. The purpose of this program is to read each character from the file, and then store each char that it read into a char array. When the whole file is done being read, then we output the array to a new file (called output.txt) that modifies all the characters to upper case and strips all the whitespaces including new lines. Also make sure to use file error checking when you perform the file operations.
I am attaching some pseudo code for this exercise.
Algorithm/Pseudo-code for Exercise 1 1. ifstream ifs; 2. char iarray1000]; 3. open the input file and check for error, i.e. ifs.open("LabInput3-1.txt'"); if (ifs.fail0) // file open failed. Probably the file does not exist, or // the file is not in the correct location. // To find out where the correction location is, you can // create an output file and open it and check where the // output file is. That is the place where input file should be. Print some message to indicate the error. exit( cstdlib? 1); // include>iarray[count++]) // empty body // This code fragment reads the integers in the file ifs to the integer // array iarray Count is the number of integers read. 5. Convert each character in jarrayll to be uppercase, using toupper) functionStep 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