Help with debugging

This is a discussion on Help with debugging within the C++ Programming forums, part of the General Programming Boards category; i am trying to see separate values of a string in C++ while i debug. IN C i was able ...

  1. #1
    Registered User
    Join Date
    Jan 2012
    Posts
    16

    Help with debugging

    i am trying to see separate values of a string in C++ while i debug.
    IN C i was able to do it but in C++ i failed.
    it doesnt show values seperately,
    I know basic debugging.

    suppose,

    i declared string s1,s2;
    i am trying to see values of each element of s1 seperately.(as an array)

    PLEASE HELP ME.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,739
    What does your debugger show you?
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Jan 2012
    Posts
    16
    I am using Codeblocks

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,739
    No, that's your IDE. I'm asking what does you debugger show you when you watch a std::string.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User
    Join Date
    Jan 2012
    Posts
    16
    ok i dont understand what std::string means.sorry.
    but when i open the watch window;
    under s1 string(as ive declared before)
    it shows
    static npos=4292967295;
    M_dataplus(you can expand it)
    it goes on

    I am just trying to view this as an array.

  6. #6
    Registered User
    Join Date
    Jan 2012
    Posts
    16
    I mean is there a way to view the elements of the string or vector in CODEBLOCKS???

  7. #7
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,650
    First link in a Google search of "debugging in code::blocks"

  8. #8
    Registered User
    Join Date
    Jan 2012
    Posts
    16
    ive watched a lot of things regarding the debugging.i can debug.in C i can see all values of a string as an array.
    But in C++ string i cant do it.
    please if you know give me a hint on how to do it.links are not working for me.

  9. #9
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,739
    Quote Originally Posted by ghost007
    M_dataplus(you can expand it)
    What do you mean by "you can expand it"? If the watch window is only showing you the value of the internal pointer, then you could try watching the pointer itself to see if the contents of what the pointer points to will be displayed instead of merely the address stored.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  10. #10
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,425
    you can usually go down through the tree expanding the little + boxes until you see the string content as text, does that not work for you? Also if you right click and explicitly add it as a watch then normally it will just show the value as an additional item in the list of variables in scope
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. need help with debugging
    By Wiggles in forum C Programming
    Replies: 4
    Last Post: 07-21-2010, 05:22 AM
  2. help on debugging
    By Masterx in forum C++ Programming
    Replies: 56
    Last Post: 01-30-2009, 09:09 AM
  3. Debugging
    By parad0x13 in forum C++ Programming
    Replies: 3
    Last Post: 08-31-2008, 06:45 PM
  4. help debugging
    By MB1 in forum C++ Programming
    Replies: 6
    Last Post: 11-03-2005, 12:48 PM
  5. help with debugging
    By Mark S. in forum C++ Programming
    Replies: 3
    Last Post: 05-19-2005, 11:50 PM

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