#include <stdio.h>
#include <stdlib.h>
struct Node
{
int item;
struct Node *nextNode;
};
void add_to_printBuffer(struct Node** head, int item)
{
struct Node* node = (struct Node*) malloc(sizeof(struct Node));
node->item = item;
node->nextNode = (*head);
(*head) = node;
}
void printList(struct Node *node)
{
struct Node* last = NULL;
while (node != NULL)
{
add_to_printBuffer(&last, node->item);
node = node->nextNode;
}
while(last !=NULL){
printf(" %d", last->item);
last = last ->nextNode;
}
}
int main()
{
struct Node* node = NULL;
add_to_printBuffer(&node, 7);
add_to_printBuffer(&node, 1);
printf("\n Files to br printed: ");
printList(node);
return 0;
}
Comments
Leave a comment