Yes :) I understand how cout works. I have been working with the DOS window for a while and now I am moving on to the windows application.
I am using graphics now and the simple i/o functions no longer appear. I have programmed a simple matching game and I am trying to output the player's scores on the screens.
The only way I have found I can do thi so far is by having a bunch of if statements like:
TextOut(hdc, 150, 750, TEXT("Player 1:"),9);
if (player1_score == 0)
TextOut(hdc, 220, 750, TEXT("0"),1);
if (player1_score == 1)
TextOut(hdc, 220, 750, TEXT("1"),1);
if (player1_score == 2)
TextOut(hdc, 220, 750, TEXT("2"),1);
if (player1_score == 3)
TextOut(hdc, 220, 750, TEXT("3"),1);
However - this seems like a lot of unnecessary code. I want to somehow output player1_score instead of all of these hardcoded strings.
Try this:
std::stringstream stream;
stream <<player1_score;
stream.str().c_str(); //<-- Use this instead of TEXT(*). Note that if UNICODE is #defined, you'll have to use a std::wstringstream.