Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write C++ program p1.cpp that reads characters from standard input and prints them in reverse order. If the input contains more than 10,000,000 bytes,
Write C++ program p1.cpp that reads characters from standard input and prints them in reverse order. If the input contains more than 10,000,000 bytes, the program must report "input too long" and return value 1. Otherwise, after printing all characters in reverse it must return value 0 Use C++'s new and delete mechanism for dynamic memory management (if needed) Test your program with various inputs and make sure that no memory is leaked, i.e., before returning from main, all allocated memory has to be returned to the operating system. Use valgrind to check this List your (short) test inputs/outputs in a comment at the end of your program Hint: You can't store big arrays on the runtime stack because it's usually quite small (a few megabytes)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Heres a C program p1cpp that reads characters from standard input and prints them in reverse order w...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