Linear list

This is a discussion on Linear list within the C Programming forums, part of the General Programming Boards category; I must create a program which sorts linear list. The list must be implemented as a pointer list, which holds ...

  1. #1
    Registered User
    Join Date
    Apr 2005

    Linear list

    I must create a program which sorts linear list. The list must be implemented as a pointer list, which holds the strings. Sorting must be ascending (in alphabetic order).

    struct list{
    char string[100]; //the value part of the list
    struct list *p_next; //a pointer to the next element of the list
    int main() {
    struct list *p_start; //a pointer which points at the start of the list
    p_start=add(p_start,"Life sucks!");
    p_start=add(p_start,"Programming can be hard!");
    p_start=add(p_start,"Nothing to say here");
    return 0;
    void print_list(struct list *p_start){ //a method to printout the list
    struct list *add(struct list *p_start,char added_value[])
      int *q;
       q=(struct list*)malloc(sizeof(struct list));//must create a pointer on that new element of the list
    Now in the above code I tried to just make some list of strings without sorting them, and each time I add a string I add it at the beginning. I get a few errors. Any help would be great. And suggestions how to sort the list too.

  2. #2
    Registered User
    Join Date
    Sep 2002
    Hey there, try taking a look here..
    - Daniel Wallace

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 26
    Last Post: 07-05-2010, 11:43 AM
  2. instantiated from here: errors...
    By advocation in forum C++ Programming
    Replies: 5
    Last Post: 03-27-2005, 09:01 AM
  3. How can I traverse a huffman tree
    By carrja99 in forum C++ Programming
    Replies: 3
    Last Post: 04-28-2003, 06:46 PM
  4. List class
    By SilasP in forum C++ Programming
    Replies: 0
    Last Post: 02-10-2002, 05:20 PM
  5. 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