#include <stdio.h>
#include <stdlib.h>

typedef struct node
{
	char Character;
	struct node *Next;
}node;

typedef struct
{
	node *Head;
	node *Tail;  
}queue;

node *alloc_node(char c, node *Next)
{
  	node *NewNode = malloc(sizeof(node));
  	NewNode->Character = c;
  	NewNode->Next = Next;
      
	return NewNode;
}

void enqueue(queue *Queue, char c)
{
	// TODO: implement this
	node *NewNode = alloc_node(c, 0);
	if(Queue->Tail)
		Queue->Tail->Next = NewNode;
	Queue->Tail = NewNode;
	if(!Queue->Head)
	{
		Queue->Head = NewNode;
	}
}


char dequeue(queue *Queue)
{
	// TODO: implement this
	node *First = Queue->Head;
	char Result = First->Character;
	Queue->Head = First->Next;
	free(First);
	return Result;
}

node *peak(queue *Queue)
{
	// TODO: implement this
	return Queue->Head;
}

int main(int argc, char **argv)
{
	queue Queue = {};
	char *String = "HelloWorld!";

	while(*String)
	{
		enqueue(&Queue, *String++);
	}
	while(peak(&Queue))
	{
		printf("%c", dequeue(&Queue));
	}
	
}
