linked list question

This is a discussion on linked list question within the C Programming forums, part of the General Programming Boards category; Hey there, new to the boards and pretty new to C. Working on an assignment dealing with linked lists, and ...

  1. #1
    Registered User
    Join Date
    Nov 2008
    Posts
    54

    linked list question

    Hey there, new to the boards and pretty new to C.

    Working on an assignment dealing with linked lists, and trying to understand them.

    Is it possible to store an array in a node for a linked list? Furthermore, is it possible to store several arrays within one node of a linked list?

    The assignment is as such: read in text file that is set up as
    Record:...
    Artist:...
    Genre:...
    Year:...

    with five+ records in the file.
    I need to read in the records and store each in a linked list. Is it possible to do this with one list, or do I do a second linked list, for each node of the main linked list? Like Linked list 1 would have nodes 1-numRecords, and each node of linked list 1 would have a linked list with nodes 1-4 (record, artist, genre, year)?

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by mikeman View Post
    Hey there, new to the boards and pretty new to C.

    Working on an assignment dealing with linked lists, and trying to understand them.

    Is it possible to store an array in a node for a linked list? Furthermore, is it possible to store several arrays within one node of a linked list?
    Since a "node" is really a structure you define yourself (there is no "linklist.h", is there?), yes, you can put whatever you want in it. The only thing you need in the struct to make it function in a linked list is a pointer to another such node:

    Code:
    struct _node {
    	char *string;
            struct record Record;
            int year;
            int chessboard[8][8];
            char etc[4];
    	struct _node *next;
    };
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linked List Not Saving Value as Int
    By bar338 in forum C Programming
    Replies: 4
    Last Post: 05-04-2009, 08:53 PM
  2. linked list question
    By brb9412 in forum C Programming
    Replies: 16
    Last Post: 01-04-2009, 04:05 PM
  3. singly linked circular list
    By DarkDot in forum C++ Programming
    Replies: 0
    Last Post: 04-24-2007, 09:55 PM
  4. singly linked list
    By clarinetster in forum C Programming
    Replies: 2
    Last Post: 08-26-2001, 11:21 PM

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