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

add set function

parent 78428385
No related branches found
No related tags found
No related merge requests found
......@@ -23,5 +23,6 @@ vector vector_create();
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);
#endif
\ No newline at end of file
......@@ -24,6 +24,12 @@ int main()
printf("Modified Vector lenght : %d and the value we popped : %d \n", vector_length(test), val);
vector_push(test, 42);
vector_set(test, 0, 69);
val = vector_pop(test);
printf("Modified Vector lenght : %d and the value we popped : %d \n", vector_length(test), val);
return 0;
......
......@@ -64,3 +64,10 @@ type vector_pop(vector vec)
return tmp;
}
void vector_set(vector vec, int index, type element)
{
assert(index < vec->length);
vec->content[index] = element;
}
\ 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