Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Showing a varible in messagebox (visual c++)

  • 07-02-2006 02:06PM
    #1
    Registered Users, Registered Users 2 Posts: 221 ✭✭


    Title says it all can somwone show how to output a varible ina messagebox i use to know how to do it by setting up a strinf and outputiing it but cant remeber the notion fot it .

    All help wud be great thanks a lot

    -S-o-d


Comments

  • Closed Accounts Posts: 268 ✭✭UberNewb


    Try this,

    int Age = 12;
    char buff[64];

    wsprintf(buff, "I am %d years old today", Age);
    MessageBox(buff, "My Age", MB_ICONINFORMATION);


  • Registered Users, Registered Users 2 Posts: 1,481 ✭✭✭satchmo


    Elfman wrote:
    Title says it all can somwone show how to output a varible ina messagebox i use to know how to do it by setting up a strinf and outputiing it but cant remeber the notion fot it.
    Lol... we're you even looking at the screen when you typed this?!


  • Registered Users, Registered Users 2 Posts: 221 ✭✭Elfman


    He he sorry was late for a class so typed in a hurry (and im not a great typist). I was talking bout it earlier and it think it's somethink along the lines of

    char Name[10];

    CString Message;
    Message = ("Hello my name is", %s, Name);
    AfxMessageBox(Message);

    but it's not working il tryt he other suggestion now thanks guys !


  • Closed Accounts Posts: 7,346 ✭✭✭Rev Hellfire


    Since its windows well assume you're using CString from atlstr.h

    CString sMessage;
    LPCTSTR szName = _T("Homework");

    sMessage.Format(_T("My name is %s."), szName);

    ::MessageBox(NULL, sMessage, _T("Title loike"), MB_OK);


  • Registered Users, Registered Users 2 Posts: 221 ✭✭Elfman


    OK thanks everyone brill one more question you know how you use %s for string and %d for int ? well whats for double ??


  • Advertisement
  • Closed Accounts Posts: 7,346 ✭✭✭Rev Hellfire


    It's in your notes.


  • Closed Accounts Posts: 268 ✭✭UberNewb


    Page 10, paragraph 3. :D


Advertisement