Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libvector
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
iliya.saroukha
libvector
Commits
c76d9188
Commit
c76d9188
authored
1 year ago
by
iliya
Browse files
Options
Downloads
Patches
Plain Diff
fix: moved implementation of printing to stdout an int to the main program
parent
fc550b26
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
struct/vec.c
+0
-13
0 additions, 13 deletions
struct/vec.c
struct/vec.h
+1
-4
1 addition, 4 deletions
struct/vec.h
vec_test.c
+13
-2
13 additions, 2 deletions
vec_test.c
with
14 additions
and
19 deletions
struct/vec.c
+
0
−
13
View file @
c76d9188
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
struct/vec.h
+
1
−
4
View file @
c76d9188
#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
This diff is collapsed.
Click to expand it.
vec_test.c
+
13
−
2
View file @
c76d9188
...
...
@@ -7,7 +7,6 @@
#define NB_OPTIONS 6
void
print_menu
(
void
)
{
fprintf
(
stdout
,
"*********** Menu opts ***********
\n
"
);
fprintf
(
stdout
,
"1:
\t
Push number
\n
"
);
fprintf
(
stdout
,
"2:
\t
Delete 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
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment