forked from tezc/sc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray_example.c
More file actions
49 lines (35 loc) · 701 Bytes
/
array_example.c
File metadata and controls
49 lines (35 loc) · 701 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "sc_array.h"
#include <stdio.h>
void example_str()
{
const char *it;
struct sc_array_str arr;
sc_array_init(&arr);
sc_array_add(&arr, "item0");
sc_array_add(&arr, "item1");
sc_array_add(&arr, "item2");
printf("\nDelete first element \n\n");
sc_array_del(&arr, 0);
sc_array_foreach (&arr, it) {
printf("Elem = %s \n", it);
}
sc_array_term(&arr);
}
void example_int()
{
struct sc_array_int arr;
sc_array_init(&arr);
sc_array_add(&arr, 0);
sc_array_add(&arr, 1);
sc_array_add(&arr, 2);
for (size_t i = 0; i < sc_array_size(&arr); i++) {
printf("Elem = %d \n", arr.elems[i]);
}
sc_array_term(&arr);
}
int main()
{
example_int();
example_str();
return 0;
}