diff --git a/struct/vec.c b/struct/vec.c index 44ace6dcf44e2459a3d90f68c555e3f2e464ffac..510c08e8827b1417492b998e7aecc311c112a0f8 100644 --- a/struct/vec.c +++ b/struct/vec.c @@ -256,19 +256,6 @@ void vec_remove(vec_t *vec, size_t idx) { free(aftr_idx); } -char *print_int(void *element) { - int64_t data = (int64_t)element; - char *s = calloc(30, sizeof(char)); - - if (s == NULL) { - perror("calloc"); - return NULL; - } - - sprintf(s, "Data: %ld |\n", data); - return s; -} - /** * @brief Function that prints out the content as well as the current length and * capacity of a given vector diff --git a/struct/vec.h b/struct/vec.h index 7ca90035094a6414ac30567a85fd65f11e3fb39d..becc2a74d6dcac2b09fe8e8d269ba0b4c2cffd4b 100644 --- a/struct/vec.h +++ b/struct/vec.h @@ -1,5 +1,4 @@ -#ifndef _VEC_H_ -#define _VEC_H_ +#pragma once #include <stdbool.h> #include <stdint.h> @@ -27,5 +26,3 @@ extern char *print_int(void *element); extern void vec_print(vec_t *vec, char *(*print_entry)(void *data)); extern void vec_destroy(vec_t **vec); - -#endif diff --git a/vec_test.c b/vec_test.c index b497f98550998c7c9793f202987a7ebc38e949b6..d220a2573fedc7cf78dd79b7aa48518dc1989855 100644 --- a/vec_test.c +++ b/vec_test.c @@ -7,7 +7,6 @@ #define NB_OPTIONS 6 void print_menu(void) { - fprintf(stdout, "*********** Menu opts ***********\n"); fprintf(stdout, "1:\tPush number\n"); fprintf(stdout, "2:\tDelete at given index\n"); @@ -18,6 +17,19 @@ void print_menu(void) { fprintf(stdout, "*********************************\n\n"); } +char *print_int(void *element) { + int64_t data = (int64_t)element; + char *s = calloc(30, sizeof(char)); + + if (s == NULL) { + perror("calloc"); + return NULL; + } + + sprintf(s, "Data: %ld |\n", data); + return s; +} + int main(int argc, char **argv) { if (argc < 2) { fprintf(stderr, "Usage:\n"); @@ -84,7 +96,6 @@ int main(int argc, char **argv) { item_poped); break; case 4: - // vec_print(new_vec); vec_print(new_vec, print_int); break; case 5: