Thread: C-Pseudo Code - Insert Question

  1. #1
    Microsoft. Who? MethodMan's Avatar
    Join Date
    Mar 2002
    Posts
    1,198

    C-Pseudo Code - Insert Question

    Code:
    typedef struct NodeTag {
    	char Letter;
    	struct NodeTag *Link;
    } NodeType;
    I am trying to use this struct, and adding an item at the beginning of a list.

    Code:
    L -> | B |  |-> | C | +|
    the + = null (end of the list)
    L points to the list. B and C are the (char Letter), and the second block is the pointer.

    so this is what I have for the insert function at the beginning

    Code:
    InsertNode(A, &L)
    {
        if(Empty(L))
           L = A;
        else
           A = L;
           L = A;
    }
    Is that right?

    Thanks
    -MethodMan-

    Your Move:Life is a game, Play it; Life is a challenge, Meet it; Life is an opportunity, capture it.

    Homepage: http://www.freewebs.com/andy_moog/home.html

  2. #2
    Microsoft. Who? MethodMan's Avatar
    Join Date
    Mar 2002
    Posts
    1,198
    Thanks, I forgot about the link part on A.
    -MethodMan-

    Your Move:Life is a game, Play it; Life is a challenge, Meet it; Life is an opportunity, capture it.

    Homepage: http://www.freewebs.com/andy_moog/home.html

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 04-02-2009, 04:40 AM
  2. insert into binary tree question..
    By transgalactic2 in forum C Programming
    Replies: 32
    Last Post: 11-18-2008, 03:21 PM
  3. Simple C++ question. Error in code somewhere.
    By Paracropolis in forum C++ Programming
    Replies: 10
    Last Post: 02-06-2006, 08:59 AM
  4. Linked List question from a newb(Need code Critique)
    By Gatt9 in forum C++ Programming
    Replies: 2
    Last Post: 01-08-2006, 03:11 AM
  5. End of Code Loop Question
    By JuanSverige in forum C++ Programming
    Replies: 1
    Last Post: 04-08-2003, 10:35 AM