1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

problems with strings

Discussion in 'C++' started by David_Omid, Aug 31, 2010.

  1. David_Omid

    David_Omid New Member

    Joined:
    Aug 31, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hey guys, I was wondering if any of you could help me with some stuff which may seem obvious to you but I'm a beginner.

    I'm making a calculator and have reached the part where I am making the buttons change the string on the calculator's "screen".

    The way I am doing this is by getting the current line of numbers as a string and then converting the number pressed into a string and then adding the two strings together to form the new calculator display, I then want to display that string.

    After reading some books and looking online I thought the best way of doing this would be to use string streaming, so I have made the following:

    Code:
     if(ButtonType == 1) // Numerical buttons processed here
                            {
                                    CurrentInputString = "";
                                    CurrentInput = 0;
                                    CurrentInput = ButtonNumber;
                                    InputOutputStream > CurrentInputString;
                                    InputOutputStream.str("");
                                    InputOutputStream.clear();
    
                                    InputOutputStream > TotalInputString;
                                    InputOutputStream.str("");
                                    InputOutputStream.clear();
    
                                    InputOutputStream  TotalInput;
                                    InputOutputStream > TotalInputString;
                                    InputOutputStream.str("");
                                    InputOutputStream.clear();
                                    this->InputLabel->Text = Convert::ToString(TotalInput);
    
                            }
    
    I had problems setting the text as "TotalInputString" and got these compiler messages:

    So my question is - how do I do this? All I want is for the string to allow me to place as many numbers as I need on the display. How do I change the text in such a way?


    This was done on Visual C++, sorry if that's a problem.


    Thanks in advance to anyone who helps.
     

Share This Page