9 ms·
You could use a linked list. Practically speaking, I might just allocate an array of 100 pointers. That's only 400 bytes. Then as you encounter each filename,
by adrianmonk 6d ago
You could use a linked list.
Practically speaking, I might just allocate an array of 100 pointers. That's only 400 bytes. Then as you encounter each filename, allocate just enough memory for the actual length of the string (plus null terminator) and store the pointer in the array.
- ulrikrasmussen 6d agoThat will require a second pass though, because you have to free all your strings again.