Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 734017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:19:25+00:00 2026-05-14T07:19:25+00:00

Well! I feel really stupid for this question, and I wholly don’t mind if

  • 0

Well!

I feel really stupid for this question, and I wholly don’t mind if I get downvoted for this, but I guess I wouldn’t be posting this if I had not at least made an earnest attempt at looking for the solution.

I’m currently working on Euler Problem 4, finding the largest palindromic number of two three-digit numbers [100..999].

As you might guess, I’m at the part where I have to work with the integer I made. I looked up a few sites and saw a few standards for converting an Int to a String, one of which included stringstream.

So my code looked like this:

//  tempTotal is my int value I want converted.
void toString( int tempTotal, string &str )
{ 
    ostringstream ss;            // C++ Standard compliant method.
    ss << tempTotal;
    str = ss.str();              // Overwrite referenced value of given string.
}

and the function calling it was:

else
{
    toString( tempTotal, store );
    cout << loop1 << " x " << loop2 << "= " << store << endl; 
}

So far, so good. I can’t really see an error in what I’ve written, but the output gives me the address to something. It stays constant, so I don’t really know what the program is doing there.

Secondly, I tried .ToString(), string.valueOf( tempTotal ), (string)tempTotal, or simply store = temptotal.

All refused to work. When I simply tried doing an implicit cast with store = tempTotal, it didn’t give me a value at all. When I tried checking output it literally printed nothing. I don’t know if anything was copied into my string that simply isn’t a printable character, or if the compiler just ignored it. I really don’t know.

So even though I feel this is a really, really lame question, I just have to ask:

How do I convert that stupid integer to a string with the stringstream? The other tries are more or less irrelevant for me, I just really want to know why my stringstream solution isn’t working.

EDIT:

Wow. Seriously. This is kind of embarrassing. I forgot to set my tempTotal variable to something. It was uninitialized, so therefore I couldn’t copy anything and the reason the program gave me either a 0 or nothing at all.

Hope people can have a laugh though, so I think this question would now be better suited for deletion since it doesn’t really serve a purpose unless xD But thanks to everybody who tried to help me!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T07:19:25+00:00Added an answer on May 14, 2026 at 7:19 am

    Have you tried just outputting the integer as is? If you’re only converting it to a string to output it, then don’t bother since cout will do that for you.

    else
    {
        // toString( tempTotal, store ); // Skip this step.
        cout << loop1 << " x " << loop2 << "= " << tempTotal << endl; 
    }
    

    I have a feeling that it’s likely that tempTotal doesn’t have the value you think it has.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've read several topics about this as well as the API and I feel
Really not sure what stack site to place this on. Feel free to move
So, I know both Java and Objective-C quite well, but (perhaps strangely) never really
I don't really know math well beyond Algebra 1, however I can usually hack
This is really starting to piss me off. I feel like I have tried
I feel like this may be a trivial problem for most people but I'm
I'm not really sure where to start on this, but I have a menu
This is very simple, but I'm being rather stupid about it. I have a
I'm using this script from Marco Kuiper and it really works amazingly well. My
Well i have a question that i feel i've been answered several times, from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.