mirror of
https://github.com/TheAlgorithms/C.git
synced 2026-02-13 13:54:36 +00:00
[BUG] Function updateValueCArray() does nothing #108
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ybrenning on GitHub (Jan 13, 2022).
Description
The function
updateValueCArray()in the implementation of arrays does not update anything.Upon checking for a correct index in line 99, the function does not actually update the value at the given index. The function will return
INVALID_POSITIONif the element at the given position is not equal to zero instead of updating the value at the given index. I would like to fix this issue by updating the function.Expected behavior
Element at index
positionshould be updated tovalueand returnSUCCESSupon doing so.Actual behavior
No element gets updated and returns
INVALID_POSITIONeven for valid positions.Possible fix
Update the value at the given index using
array->array[position] = value;and add a return statementSteps to reproduce
CArraydisplayCArray()updateValueCArray()function with a valid index and valuedisplayCArray()Context
I was trying to understand the implementation while reading through the source code and found this function which I could not make sense of
Additional information
No response