I am trying to do this in C. Lets say I have a do while loop. At the start of each loop it initializes a char
that contains a path (e.g /a/b/c). So after each loop the value changes (e.g /b/c/d).
What I would like to do is at the end of each loop before the start of the next loop, store the value into an Array
. Since I do not know the size of my Array
, I cannot use a static array in C.
I know it is easily achievable in java such as using an ArrayList to store my values, but that is java and this is C so I know it is completely different.(Sorry I just started learning C)
List<String> myList = new ArrayList<String>();
myList.add(path);
I would like to know if there is a similar alternative in C. I have look at some example such as link but this uses int. How would store a char containing a file path.
Edit:
If possible I hope someone could provide a solution in the answers with my requirements, that is to insert char into an array or using a linked list?