Question: 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

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

1 Expert Approved Answer
Step: 1 Unlock

Heres a C program p1cpp that reads characters from standard input and prints them in reverse order w... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!