NB: Square bracket notation for array access is NOT allowed for Question 3, i.e. array[i]. Array access MUST be facilitated by the use of pointers.
Write a function, ReadFile(), that reads the content of the provided text file “Message.txt” and stores it in an array. The function receives as parameter a pointer to a character array where the content of the text file should be stored.. The number of lines that was read from the text file must be returned to the calling statement.
Write a function, ReverseMyString(), that converts the character array (which now contains the contents of the text file) by replacing the first character with the last character, the second character replaced with the second last character, etc, until the message is reversed as shown in the Figure 3. The function receives as parameters, a pointer to the character array and an integer value indicating the length of the array. The function returns a 1 or 0 to indicate success and failure respectively. NB: You must write your own function. The strrev()- function may not be used.
Write a function, WriteFile(), which stores information in a text file. The function receives as parameter a pointer to the character array that has to be written to the text file. Name the output file “Output.txt”. The function returns no value to the calling statement.
The above functions (ReadFile(), ReverseMyString(), and WriteFile()) must now be implemented in the main program (main()) in the following order with a fitting message as in Figure 3: 1. Create an array of type character and make provision for a maximum of 100 elements. 2. Read the contents of the text file “Message.txt” to the array with ReadFile(). 3. Call the ReverseMyString() function to reverse the content of the array. 4. Write the reversed character array to an output file with WriteFile().
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 1 images
- 1. declare an array to hold 12 floating point numbers: 2. Now that we have our array, set all 12 numbers to -100. 3. Change all even positions (all lines with an even index: 0,2,4, etc) to 96.8Use a function call to print the array.arrow_forwardWrite three functions for: mean, remove, display //include any standard libraries needed // - passes in an array along with the size of the array // - returns the mean of all values stored in the array double mean( const double array [ ], int arraySize); // - Passes in an array, the size of the array by reference, and the index of a value to be removed from the array. // - Removes the value at this index by shifting all of the values after this value up, keeping the same relative order of all values not removed. // - Refuces arraySize by 1. void remove (double array[], not &arraySize, int index); // - Passes in an array and the size of the array. // - outputs each value in the array separated by a comma and space, with mo comma, space or beeline at the end. void display (const double array[], int arraySize); const int ARR_CAP = 100; int main (int argc, char *argv[]){// verify file name provided on command line // open file and verify it opened // declare an array of doubles of…arrow_forwardWrite the function lastOf which searches the array a for the last occurance of any value contained in the array b. Returns the index if found. If not found, return -1. arrays.cpp 1 #include 2 int last0f(const int a[], int alen, const int b[], int bLen) { 3 4 5 6 7 8 }arrow_forward
- 1- Write a user-defined function that accepts an array of integers. The function should generate the percentage each value in the array is of the total of all array values. Store the % value in another array. That array should also be declared as a formal parameter of the function. 2- In the main function, create a prompt that asks the user for inputs to the array. Ask the user to enter up to 20 values, and type -1 when done. (-1 is the sentinel value). It marks the end of the array. A user can put in any number of variables up to 20 (20 is the size of the array, it could be partially filled). 3- Display a table like the following example, showing each data value and what percentage each value is of the total of all array values. Do this by invoking the function in part 1.arrow_forwardC programarrow_forward1. You have an array of 4 ints which is sorted from highest to lowest. You also have a function which runs a bubble sort to sort items from lowest to highest. If you run this function on your array, the function will do multiple swaps. A) True B) Falsearrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education