Thread: LINK LIST program ....Pls HELP....??

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    1

    Post LINK LIST program ....Pls HELP....??

    hey someone pls tell what is the error ( any type) in this program of link list which i have made ,, actually i am a student and when i showed this program to my teacher he told that there are errors in this and told me to find them out but i am not able to do soo ,, pls someone help ,, i have attached my program

  2. #2
    Registered User dinjas's Avatar
    Join Date
    Feb 2005
    Location
    Vancouver, Washington
    Posts
    40
    Why don't you try compiling it with all of your compiler's warnings enabled?
    For my compiler (gcc) I tell it to give me more warnings and to nitpick by using
    the
    Code:
    -pedantic
    switch to nitpick and the
    Code:
    -Wall
    switch
    to give me all the warnings it can/will.
    straight off the heap

  3. #3
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    main MUST return int, not void.
    Don't cast the return result of malloc. The fact that you purposefully mis-spelt 'delete' shows that you are incorrectly using a C++ compiler for C code.
    Using 'goto' was an awful decision, use a 'break' instead.
    Your indentation is horrible. Also don't mix tabs and spaces.

    Most of your problems are mentioned in the FAQ, so read it now.

    Your teacher will not appreciate txt spk, and neither do I.
    "ur" is not how to spell "your"...
    "b" is not how to spell "be"...
    "b4", well words don't contain digits...
    "please" is not spelt "pls"...
    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. #4
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,058
    One of the most glaring problems is that you only define a local node structure in all your functions which goes out of scope when you exit the function. I would suggest that you only define one node pointer structure in main and pass this node structure to your functions. The create, insert1 and insert2 functions would probably need a double pointer parameter and you would pass the address of the node pointer in main to these functions.

  5. #5
    Registered User
    Join Date
    Apr 2008
    Location
    New Delhi,India
    Posts
    17
    Hi,

    I have compiled your program it runs fine.But you should not declare main() as void.Some compiler does not take main as void rather declare main() as int and return 0(return 0 in main.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ Linked list program need help !!!
    By dcoll025 in forum C++ Programming
    Replies: 1
    Last Post: 04-20-2009, 10:03 AM
  2. Pleas take a look & give a critique
    By sh3rpa in forum C++ Programming
    Replies: 14
    Last Post: 10-19-2007, 10:01 PM
  3. Replies: 6
    Last Post: 03-02-2005, 02:45 AM
  4. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  5. singly linked list
    By clarinetster in forum C Programming
    Replies: 2
    Last Post: 08-26-2001, 10:21 PM