Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions 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!
expand button
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
Check Mark
Knowledge Booster
Background pattern image
Computer Science
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
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education