Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
ScribeOfGoD719380dOpens command line: tree
There ya go 😂😉
Fast-Nop2249980dIt's just a struct with arbitrary data part and an array of pointers for the next depth level. Traversing is a recursive function with a for loop inside.
Or you make the pointer array of dynamic length with calloc, doesn't change much.
Haxk204283980dWell im of to work so i will look at this in morning.
Haxk204283979dBTW i found the solution when i thinked about it on my own. just an array of nodes with pointer to previous and next node and the ID of that node.
And to find that path i just search from the node i need up until i hit beginning and then i take the second node i have to reach and search up until i hit common node. Then i just add the number of steps and done.
Little weird having "object" in C but hey it worked.
@Haxk20 Objects do not require dedicated language implementation. A lot of other languages with object implementations (python, for example) are written in C and handle objects just fine, because an object is a conceptual thing above what C provides, but not beyond what can be implemented in it.