-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvector.c
More file actions
35 lines (29 loc) · 823 Bytes
/
Copy pathvector.c
File metadata and controls
35 lines (29 loc) · 823 Bytes
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
#include "vector.h"
typedef char* string;
typedef struct {
int x, y;
} Tuple;
int main(void)
{
printf("Output for String:\n");
qvec(string) *sv = qvec_new(string, "Who", "are", "you?");
qvec_print(sv);
qvec_at(sv, 2) = "we?";
qvec_print(sv);
qvec_free(sv);
printf("\nOutput for int:\n");
qvec(int) *iv = qvec_new(int, 1, 2, 3, 4);
qvec_print(iv);
printf("%d\n", qvec_pop(iv));
qvec_free(iv);
printf("\nOutput for Double:\n");
qvec(double) *dv = qvec_new(double, 1, 2, 3, 4);
qvec_print(dv);
printf("%lf\n", qvec_pop(dv));
qvec_free(dv);
printf("\nOutput for Tuple:\n");
qvec(Tuple) *tv = qvec_new(Tuple, { .x = 0, .y = 1 }, { 4, 2 }, { 5, 4 });
printf("%d\n", qvec_at(tv, 1).x);
printf("%d\n", qvec_at(tv, 2).x);
qvec_free(tv);
}