need some advice on displaying values

This is a discussion on need some advice on displaying values within the Windows Programming forums, part of the Platform Specific Boards category; Ok, the topic is quite misleading but more or less, it spreads my difficulties. So far in my work of ...

  1. #1
    rEtaRD r HUMANS TOO !!! rEtard's Avatar
    Join Date
    Feb 2005
    Posts
    80

    need some advice on displaying values

    Ok, the topic is quite misleading but more or less, it spreads my difficulties.
    So far in my work of Windows Programming, i realised i always have trouble finding the values of my variables. For ETC. im currently working with GetCurrentDirectory and GetModuleFilename. In the functions, im supposed to pass a TCHAR buffer for the function to retrieve my file path, but the problem is, i don't know how to display the value, if only i know whats the value den i can understand more abt what im working with. I tried using the breakpoint on my VisualC++ but the values returned as 0*blahblah blah, i think those r pointers address. I wanna use MessageBox to display the values, i think thats the easiest way but i have no idea how should i go on with doing it.
    Can someone tell me how do i use a MessageBox or something relevant to display the Values of a variable/struct/macro or anithing ? I believe i should be looking for MessageBox that works like printf("%d",<Variable name>) Can someone advice ?
    /* Have a nice day */

  2. #2
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,266
    If you're asking what I think you're asking, then you would use wsprintf in conjunction with MessageBox, i.e:-
    Code:
    char szMessage[256];   // Message buffer.  256 bytes = 255 ANSI chars + null or 127 Unicode chars + null
    int i;   // The value you want to display
    
    i = 12345;
    wsprintf(szMessage, "i = %d", i);
    MessageBox(NULL, szMessage, "What you wanted", MB_ICONINFORMATION);

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    Another possible solution is CString Format().

    Kuphryn

  4. #4
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    Better advice would be to learn how to use the debugger. I assure you, you will save hours of wasted time with debugging statements if you learn th every few steps it takes.
    to use the right tool.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  5. #5
    rEtaRD r HUMANS TOO !!! rEtard's Avatar
    Join Date
    Feb 2005
    Posts
    80
    adrianxw, how do i use the debugger ? are you referring to the break points ?
    /* Have a nice day */

  6. #6
    rEtaRD r HUMANS TOO !!! rEtard's Avatar
    Join Date
    Feb 2005
    Posts
    80
    Smurf ! Thanx A Lot !!! That Was What I Wanted
    /* Have a nice day */

  7. #7
    rEtaRD r HUMANS TOO !!! rEtard's Avatar
    Join Date
    Feb 2005
    Posts
    80
    Smurf, can u show me how to use wsprintf() to display char variables ? or string arrays
    /* Have a nice day */

  8. #8
    rEtaRD r HUMANS TOO !!! rEtard's Avatar
    Join Date
    Feb 2005
    Posts
    80
    Sorrie, i found the solution alreadi, i was just hesitating whether i should use %s as the format specifications, msdn said to avoid it for buffer over-run
    /* Have a nice day */

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Displaying values of variables to a Form
    By Cielo in forum C++ Programming
    Replies: 1
    Last Post: 03-07-2008, 03:47 AM
  2. Sending values to a control
    By Zyk0tiK in forum C Programming
    Replies: 6
    Last Post: 12-02-2005, 06:29 PM
  3. Displaying numerical values in a window
    By drb2k2 in forum C++ Programming
    Replies: 1
    Last Post: 04-08-2003, 01:05 PM
  4. unsigned char vs signed char and range of values
    By Silvercord in forum C++ Programming
    Replies: 5
    Last Post: 01-22-2003, 01:30 PM
  5. adding ASCII values
    By watshamacalit in forum C Programming
    Replies: 1
    Last Post: 12-26-2002, 07:16 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21