Skip to content

Commit

Permalink
add array library example
Browse files Browse the repository at this point in the history
  • Loading branch information
sulincix committed Aug 28, 2024
1 parent 04f7c28 commit 08c1b44
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions example/application/array.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* ymp header */
#include <ymp/array.h>
/* for printf */
#include <stdio.h>
/*
Build command:
gcc `pkg-config --cflags --libs ymp` array.c -o array
*/

int main(int argc, char** argv){
/* define array */
array *a = array_new();
/* add items */
array_add(a,"hello");
array_add(a,"world");
array_add(a,"test");
/* delete item */
array_remove(a,"test");
/* get all items */
int len=0;
char** arr = array_get(a,&len);
/* print items */
for(int i=0;i<len;i++){
printf("%s\n",arr[i]);
}
return 0;
}

0 comments on commit 08c1b44

Please sign in to comment.