linked list inserting

This is a discussion on linked list inserting within the C++ Programming forums, part of the General Programming Boards category; newbie needs help with this... can anybody help?...

  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
    21,461
    Please read our homework policy. You need to put in some effort, show what you have done, before help is given.
    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
    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, 03:09 AM
  2. Adding directory/file names to a linked list
    By thoseion in forum C Programming
    Replies: 13
    Last Post: 12-08-2006, 12: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, 07:34 AM
  4. Template Class for Linked List
    By pecymanski in forum C++ Programming
    Replies: 2
    Last Post: 12-04-2001, 08:07 PM
  5. singly linked list
    By clarinetster in forum C Programming
    Replies: 2
    Last Post: 08-26-2001, 10:21 PM

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