Thread: Help with my linked list

  1. #16
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    You're running into problem after problem because you're not learning enough about what your program actually does. Seriously, run the program in a debugger and step through it one line at a time.
    What you're doing is like coming up with a bunch of directions about precisely what turns to take to your cab driver then going to sleep and waking up at the wrong destination. What you need to do is the equivalent of staying awake to see where he makes a wrong turn so that you can correct your directions. That equivalent change to staying awake is to use the debugger.
    You step through the code one line at a time and see where it goes wrong. Tell us what programming environment you're using so we can help you to use your debugger, then you can stop programming in the dark.

    Otherwise known as "Give a man a fish and he'll eat for a day; teach a man to fish and ...".
    'cause I think I'm done handing out fishes for today...
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  2. #17
    Registered User
    Join Date
    Apr 2011
    Posts
    135
    I am not good in using a debugger. I did not learn how to use it.

  3. #18
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Quote Originally Posted by evildotaing View Post
    I am not good in using a debugger. I did not learn how to use it.
    "did not learn" doesn't really make sense here unless you're about to quit programming forever.
    Learning to use a debugger is not optional for programming. All you can say is that you "have not learnt how yet".

    Using a debugger is absolutely essential to being a programmer. There is no avoiding it. Tell us what programing environment you are using and we will help you get started.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  4. #19
    Registered User
    Join Date
    Apr 2011
    Posts
    135
    microsoft visual studio 2008 , c++ books never teach how to use a debugger

  5. #20
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    See that "debug" menu in the IDE? That's your best friend.
    There are several important commands, and I will teach you a few.

    Step into: tells the debugger to execute one line of code and then stop. If the line is a function, then the debugger jumps into the function and then stops.
    Step over: tells the debugger to execute one line of code and then stop. If the line is a function, it executes the entire function, then stops.
    Step out: tells the debugger to continue executing the function you're currently in, and then stop once it's finished (has returned).

    Breakpoints can be used to tell the debugger to stop at a specific point in your program. To create a breakpoint, left-click in the margin next to the line you want it to stop at.
    To start debugging, choose debug -> start debugging. The debugger will run the program up to the next breakpoint. Alternatively, you can choose step in to have the debugger stop at the first line of your code.

    You can hover your mouse over variables to see their values. You can also make code changes and recompile that without having to restart. You will find that under Debug -> apply code changes.
    You may find the watch window (bottom left), autos and local variables to be useful to watch or see values of variables.
    The call stack shows what functions has called what and can be found in the lower right bottom.

    Experiment with these functions and see what you can learn.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Copying a linked list into another linked list
    By paranoidgnu in forum C Programming
    Replies: 7
    Last Post: 07-19-2011, 06:21 PM
  2. Replies: 4
    Last Post: 05-01-2010, 10:19 PM
  3. single linked list to double linked list (help)
    By Countfog in forum C Programming
    Replies: 8
    Last Post: 04-29-2008, 08:04 PM
  4. singly linked list to doubly linked list
    By t48j in forum C Programming
    Replies: 3
    Last Post: 03-23-2005, 06:37 PM
  5. Replies: 6
    Last Post: 03-02-2005, 02:45 AM