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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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().

 

File read successfully!
Original message:
I can Read and Write to files in C/C++
Reversed message:
++C/C ni selif ot etirW dna daer nac I
File saved successfully!
Transcribed Image Text:File read successfully! Original message: I can Read and Write to files in C/C++ Reversed message: ++C/C ni selif ot etirW dna daer nac I File saved successfully!
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education