58 lines
797 B
C
58 lines
797 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
typedef struct node
|
|
{
|
|
char Character;
|
|
struct node *Next;
|
|
}node;
|
|
|
|
typedef struct
|
|
{
|
|
node *Top;
|
|
}stack;
|
|
|
|
node *alloc_node(char c, node *Next)
|
|
{
|
|
node *NewNode = malloc(sizeof(node));
|
|
NewNode->Character = c;
|
|
NewNode->Next = Next;
|
|
|
|
return NewNode;
|
|
}
|
|
|
|
void push(stack *Stack,char c)
|
|
{
|
|
// TODO: implement this
|
|
}
|
|
|
|
// NOTE: as last time free the node here
|
|
char pop(stack *Stack)
|
|
{
|
|
// TODO: implement this
|
|
return 0;
|
|
}
|
|
|
|
node *peak(stack *Stack)
|
|
{
|
|
// TODO: implement this
|
|
return 0;
|
|
}
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
stack Stack = {};
|
|
char *String = "!dlroW ollaH";
|
|
|
|
// When everything works, the program should print Hello World!.
|
|
while(*String)
|
|
{
|
|
push(&Stack, *String++);
|
|
}
|
|
while(peak(&Stack))
|
|
{
|
|
printf("%c", pop(&Stack));
|
|
}
|
|
|
|
}
|