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

Urgent help needed please

  • 16-03-2005 3:24pm
    #1
    Registered Users, Registered Users 2 Posts: 221 ✭✭


    Hi i hope some can help me

    i need to out put a varible in a message box so i can see where the value is being corrupted it's a char[15] ,

    i'm using visual c++ 6.0

    thanks


Comments

  • Registered Users, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


       MessageBox(&my_char, "Corrupt?", MB_ICONQUESTION | MB_OK);
    

    Something like that perhaps. I could be wrong as I don't know C++. Although I suspect the char[15] is actually an array so you'll have to loop through each element, heh.


  • Registered Users, Registered Users 2 Posts: 2,281 ✭✭✭DeadBankClerk


    Elfman wrote:
    Hi i hope some can help me

    i need to out put a varible in a message box so i can see where the value is being corrupted it's a char[15] ,

    i'm using visual c++ 6.0

    thanks

    You could use the debugger...
    And set a breakpoint on the variable set to trigger when the memory is written to.


  • Registered Users, Registered Users 2 Posts: 6,570 ✭✭✭daymobrew


    While the debugger is the best option, the code for putting in a message box is:
    char my_char[15];
    
    /* code to initialise and corrupt my_char goes here */
    
    /* Remove the & from earlier suggestion. */
    MessageBox(my_char, "Corrupt?", MB_ICONQUESTION | MB_OK);
    


  • Registered Users, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


    Soz, I thought LPCTSTR meant it required a pointer. My bad.


  • Registered Users, Registered Users 2 Posts: 4,003 ✭✭✭rsynnott


    Evil Phil wrote:
    Soz, I thought LPCTSTR meant it required a pointer. My bad.

    It does. Where you have char test[20];, test IS a pointer, to that array. :)


  • Advertisement
  • Closed Accounts Posts: 447 ✭✭MickFarr


    Here ya go,
    //////////////////////////////////////////////////////////////////////////////
    // FUNCTION : DisplayChars		                                    //
    // PURPOSE  :                                                               //
    //////////////////////////////////////////////////////////////////////////////
    void CClassName::DisplayChars() 
    {
       char buff[128];
       char MyChar[] = "How much wood could a would chuck chuck if a wood chuck could chuck chukwa";
    
       // Display messagebox for char[15]
       wsprintf(buff, "char 15 = %c", MyChar[15]);
       MessageBox(buff, "Character Number 15", MB_OK);
    
       // Or you can Loop through all the characters
       for(int i=0;  i < strlen(MyChar); i++)
       {
          wsprintf(buff, "char pos %d = %c\\nPress yes to continue", i, MyChar[i]);
          if(MessageBox(buff, "Character Loop", MB_ICONQUESTION | MB_YESNO) == IDNO)
             break;
       }
    	
    }
    


Advertisement