Jump to content

C++ MessageBox() and showing interger variables


Recommended Posts

 am trying to use messagebox() like msgbox(), but harder then I think. I have tried many variations online, but not actually show me the values

int var1 = 10

int var2 = 20

I want to have the message box show the two values along with text explaining which number is showing

sudocode

showstring = 'Variable 1 ' & var1 & ' variable 2 ' & var2

messagebox(NULL, showstring)

How do I go about doing this? Any links or code would be helpful - Thanks

EDIT

Update title to reflect that this is a function for C++

Link to post
Share on other sites

Hello. This should work.

#ifndef UNICODE
#define UNICODE
#endif

#include <iostream>
#include<windows.h>

using namespace std;

int main()
{
     int var1=10;
     int var2=20;
     std::wstring s = L"Var1 = " + std::to_wstring(var1) + L"\r\nVar2 = " + std::to_wstring(var2);
     MessageBox(NULL, s.c_str(),L"Title",MB_OK);
    return 0;
}

Saludos

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...