Thread: Linked Lists?!

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Nov 2010
    Posts
    17

    Linked Lists?!

    Hello! I am taking a beginning C class at my school and the requirements for this homework is to make a game using linked lists.
    The requirements with linked lists are
    - To draw elements of linked lists
    - Moving elements around in linked lists
    - and adding/removing elements to/from a linked list

    So before I started my implementation of a linked list, I just wrote the code for my game, I decided to do a pong game, in structure/dynamic memory format because I have no clue what a linked list is lol.

    Code:
        typedef struct _position{
            int row;
            int col;
        }Position;
        Position* pos = (Position*)malloc(sizeof(Position));
    
        pos[0].col = 50;
        pos[0].row = 5;
        pos[1].col = 20;
        pos[1].row = 135;
        pos[2].col = 120;
        pos[2].row = 80;
    That is the code of my position structure that updates for where the paddles and the balls are (two paddles and one ball). I was wondering how I could easily just convert this into a linked list?

    I have my game working but now and I just want to convert my structure data into linked list format... i've been trying to figure out what a linked list is and from what I understand it is just a way of storing information...

    Is there any simple way of just making a basic linked list structure that I can add and pull elements to and from like my structures?
    Our class doesn't have a textbook so i've been trying to google everything but to no avail.

    Thanks.
    Last edited by hwing91; 11-02-2010 at 06:52 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Singly Linked Lists: Clarification Needed
    By jedispy in forum C++ Programming
    Replies: 4
    Last Post: 12-14-2006, 05:30 PM
  2. Linked Lists 101
    By The Brain in forum C++ Programming
    Replies: 5
    Last Post: 07-24-2004, 04:32 PM
  3. Map file formats and linked lists
    By Spitball in forum Game Programming
    Replies: 2
    Last Post: 03-04-2004, 11:32 PM
  4. need help w/ linked lists
    By MKashlev in forum C++ Programming
    Replies: 11
    Last Post: 08-05-2002, 08:57 PM
  5. doubly linked lists
    By qwertiop in forum C++ Programming
    Replies: 3
    Last Post: 10-03-2001, 06:25 PM