Get help on this challenge

Debugging11


Please read this explanation before attempting debugging challenges.


My code runs just fine, but I still think there's something wrong with it. Any ideas?

//Made by COM
#include<iostream>
#include<string>
using namespace std;

int main()
{
 string input;
 char* temp;
 cout<<"Input line for reversal: ";
 getline(cin, input);
 int length=input.length();
 for(int i=0; i<length; i++)
 {
  temp=new char;
  *temp=input.at(i);
  input.at(i)=input.at(length-1);
  input.at(length-1)=*temp;
  --length;
 }
 delete temp;
 cout<<"Your reversed line is: "<<input;
 return 0;
}

Downloadable source code can be found here.


You must be logged in to play.



Challenge by COM.