Question: Debug#1 int main() { char* ptr; int size; cout < < Enter the size of the sentence: ; cin >> size; ptr = new char[size];

Debug#1

int main() { char* ptr; int size; cout << "Enter the size of the sentence: "; cin >> size;

ptr = new char[size];

char* ptr2 = ptr; cout << static_cast(ptr2) << endl; cout << static_cast(ptr) << endl; cout << " Enter your sentence:" << endl; for (int i = 0; i < size; i++) { cin >> *(ptr + i); }

for (int i = 0; i < size; i++) { cout << *(ptr2 + i); }

for (int i = 0; i < size - 1; i++) { ptr2++; } cout << endl << static_cast(ptr2) << endl; while (static_cast(ptr2) > static_cast(ptr)) { cout << *ptr2; ptr2--; }

for (int i = 0; i < size; i++) { cout << *ptr2; } //cout << *ptr2 << endl;

cout << endl << static_cast(ptr2) << endl; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!