-
Notifications
You must be signed in to change notification settings - Fork 0
/
stacks_example.c
60 lines (50 loc) · 1.35 KB
/
stacks_example.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <stdio.h>
#include <stdlib.h>
#include "stacks.h"
#include "utils.h"
int main(int argc, char* argv[])
{
// if (argc == 1)
// {
// printf("Pass values to form the array\n");
// return EXIT_FAILURE;
// }
// const int n = argc - 1;
// int arr[n];
// for (int i = 1; i < argc; i++)
// {
// arr[i - 1] = atoi(argv[i]);
// }
Stack* stack = LibStack.create(NULL, 0, sizeof(char*));
// char* a = "John";
// int a = 5;
// void* x = (void*)a;
// printf("%s\n", (char*)x);
// for (int i = 0; i < 5; i++)
// {
// void* x = s[i];
// printf("%c ", *(char*)x);
// }
// puts("Pushing onto stack");
LibStack.push_str(stack, "Andrew");
LibStack.push_str(stack, "Frank");
LibStack.push_str(stack, "Jun An");
// a = 2;
// LibStack.push(stack, &a);
// a = 3;
// LibStack.push(stack, &a);
// a = 4;
// LibStack.push(stack, &a);
// LibStack.push(stack, int_to_void(1));
// LibStack.push(stack, CONVERT(2));
// LibStack.push(stack, CONVERT(3));
// LibStack.push(stack, CONVERT(4));
puts("Printing");
LibStack.print(stack, print_str);
LibStack.is_empty(stack);
LibStack.pop(stack, NULL);
puts("Printing");
LibStack.print(stack, print_str);
LibStack.free(stack, NULL);
return EXIT_SUCCESS;
}