Thread: Help with debugging

  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
    28,413
    What does your debugger show you?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    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
    28,413
    No, that's your IDE. I'm asking what does you debugger show you when you watch a std::string.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    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
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    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
    28,413
    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.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    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,472
    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, 10: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, 01:48 PM
  5. help with debugging
    By Mark S. in forum C++ Programming
    Replies: 3
    Last Post: 05-19-2005, 11:50 PM