I want to implement an index/counter to my linked list.
Why? I wrote a search function which searches the list for elements
based on their values (say I add an element and I assign the value 54
and the next element 789 and so on...) now I'd like to write a search
function which would search the list for elements based on their index.
Say first element is 54 and index 1, second element is 789 and index 2
so when I want to search, I'll do Search index: 2 and it will return
789.
How should I do that? I was thinking of making a global int counter = 0
and then in the add_to_beginning function I would do counter++ and the
same with other functions but that would only increment the counter, it
wouldn't index my elements.
Please, no pre-made libraries or OOP.I'm doing this with structures,
then I'll move to OOP.