Skip to content
Snippets Groups Projects
Commit c76d9188 authored by iliya's avatar iliya
Browse files

fix: moved implementation of printing to stdout an int to the main program

parent fc550b26
Branches
No related tags found
No related merge requests found
......@@ -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
......
#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
......@@ -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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment