Thread: Linked List

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    66

    Linked List

    I am currently learning linked list and our proff gave us this code but I can't seem to compile it, what's the problem here?


    Code:
    #include<stdio.h>
    #include<stdlib.h>
    #include<string.h>
    
    struct node
    {
           int x;
           struct node *next;
           };
           
           int main()
           {
              struct node *root;
              struct node *conductor;
              conductor=root;
              root = malloc(sizeof(struct node));
              root->next=0;
              root->x=5;
           
               while(conductor->next!=0);
               {
                  printf("%d",conductor->x);
                  conductor=conductor->next;
                                           
                                           }
    
               system("pause");
               }
    I can't seem to print the value of x :| why is it like that?


    (EDIT Done with the tagging )
    Last edited by kyel_dai92; 03-19-2011 at 03:54 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ Linked list program need help !!!
    By dcoll025 in forum C++ Programming
    Replies: 1
    Last Post: 04-20-2009, 10:03 AM
  2. Following CTools
    By EstateMatt in forum C Programming
    Replies: 5
    Last Post: 06-26-2008, 10:10 AM
  3. Reverse function for linked list
    By Brigs76 in forum C++ Programming
    Replies: 1
    Last Post: 10-25-2006, 10:01 AM
  4. Template Class for Linked List
    By pecymanski in forum C++ Programming
    Replies: 2
    Last Post: 12-04-2001, 09:07 PM
  5. singly linked list
    By clarinetster in forum C Programming
    Replies: 2
    Last Post: 08-26-2001, 10:21 PM