ProAnswers.org

algorithm to Print the nodes of a linked list

algorithm Print the nodes of a linked list

typedef struct node{

	    int data;

	    struct node *next;

	}node;

	 

	void printlist(node *head){

	    node *list;

	    list = head;

	    for(; list != NULL; list = list->next){

	        if(list->next!=NULL)

	        //if-else is just for better formatting

	            printf("%d->", list->data);

	        else

	            printf("%d", list->data);

	    }

	}