Problem not found

I created a program based off this Project Euler problem. https://projecteuler.net/problem=4
I managed to get my program to work, however it doesn't work the way I expect it to. I've had my teacher look over it and even he can't understand why it doesn't perform the way I expect it to. Perhaps the expert programmers here could help me figure out what's off.

#include <iostream>
#include <string>
#include <sstream>

using namespace std;

int main()
{
ostringstream convert;
string check, reversed;

const int largest3dignum = 999;
long currentnum;
long largestpalindromic;

for(int x=100; x<=largest3dignum; x++)
{
for(int y=100; y<=largest3dignum; y++)
{
currentnum=x*y;

convert << currentnum;
check = convert.str(); //converts the current number to string
reversed = string(check.rbegin(), check.rend()); //reverses string and stores in reversed
if(check==reversed) //if both strings are equal the current number becomes the largest palindrome
largestpalindromic = currentnum;
}
}

cout << "The largest palindrome is " << largestpalindromic << endl;

return 0;
}

As you see my primary method of identifying a palindrome is converting the current calculated value to a string, and the inverting that string (stored in another string variable) and compare both strings to see if they match. If so the number being calculated is named the largest palindrome until another is found.
I look forward to your responses.
Edit: This was an accidental repost of a post I attempted, the site told me there was an error and it wasn't posted. Refer to this post instead. http://www.cplusplus.com/forum/general/177483/
Last edited on
closed account (48T7M4Gy)
Publicly posting (near) solutions to Project Euler problems is not to be encouraged.
closed account (48T7M4Gy)
http://www.cplusplus.com/forum/general/177483/
Topic archived. No new replies allowed.