Thread: linked list inserting

  1. #1
    Registered User
    Join Date
    Jul 2007
    Posts
    3

    Smile linked list inserting

    newbie needs help with this...


    can anybody help?

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Please read our homework policy. You need to put in some effort, show what you have done, before help is given.
    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
    Jul 2007
    Posts
    3

    sorry

    ok sorry...

    i tried to do with inserting but it doesnt work this is my algorithm...
    Code:
    where s=array size and p=position
    void insert (int a[], int s, int p)
    {
    for (int i=s; i<p-1; i++)
    a[i]=a[i+1];
    a[p]=a[i];
    s++;
    }
    for (i=0; i<s; i++)
    cout<<a[i];
    any help?

  4. #4
    The larch
    Join Date
    May 2006
    Posts
    3,573
    There is no linked list in sight in your code. That's trying to insert into a plain old array.
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Unknown memory leak with linked lists...
    By RaDeuX in forum C Programming
    Replies: 6
    Last Post: 12-07-2008, 04:09 AM
  2. Adding directory/file names to a linked list
    By thoseion in forum C Programming
    Replies: 13
    Last Post: 12-08-2006, 01:13 PM
  3. Inserting new nodes in a sorted double linked list
    By carrja99 in forum C++ Programming
    Replies: 2
    Last Post: 03-07-2003, 08:34 AM
  4. Template Class for Linked List
    By pecymanski in forum C++ Programming
    Replies: 2
    Last Post: 12-04-2001, 09:07 PM
  5. singly linked list
    By clarinetster in forum C Programming
    Replies: 2
    Last Post: 08-26-2001, 10:21 PM