Skip to content
Snippets Groups Projects
Commit c59f139c authored by abivarma.kandiah's avatar abivarma.kandiah
Browse files

Add vector get

parent 27dfdbe9
No related branches found
No related tags found
No related merge requests found
......@@ -24,5 +24,6 @@ int vector_length(vector vec);
void vector_push(vector vec, type element);
type vector_pop(vector vec);
void vector_set(vector vec, int index, type element);
type vector_get(vector vec, int index);
#endif
\ No newline at end of file
......@@ -26,9 +26,9 @@ int main()
vector_push(test, 42);
vector_set(test, 0, 69);
val = vector_pop(test);
val = vector_get(test, 0);
printf("Modified Vector lenght : %d and the value we popped : %d \n", vector_length(test), val);
printf("Modified Vector lenght : %d and the value we setted : %d \n", vector_length(test), val);
......
......@@ -70,4 +70,11 @@ void vector_set(vector vec, int index, type element)
assert(index < vec->length);
vec->content[index] = element;
}
type vector_get(vector vec, int index)
{
assert(index < vec->length);
return vec->content[index];
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment