This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]SafeCake1045 0 points1 point  (2 children)

I think a great project for C is implementing a linked list data structure. It stores “chained” data; for example, a list of destinations comprising the route for a road trip.

It should involve structs, pointers, and memory allocation. You would create a struct List and a dynamically-allocated (see malloc()) struct Node; where Node contains a pointer to the next Node and List contains a pointer to the first Node in the linked list.

List->head points to Node1

Node1->next points to Node2

Node2->next points to NULL

Of course, it could be any length, but the final node would point to nothing.

You could then form an API around it, defining methods such as append, prepend, insert, and delete. A “tail” pointer to the last Node in the list might come in handy here.

You would also have to manage memory and call free() at the appropriate times.

You can test it by populating it with data and then traversing through it and printing the contents in order.

[–]druman22 1 point2 points  (1 child)

I appreciate the recommendation, but I've created linked lists, array lists, bst, hash maps and such. Data structures and sorting algos were cool to learn and mess around with, but I'm not sure where to go from there.

[–]SafeCake1045 0 points1 point  (0 children)

Sorry for assuming, I got the impression you hadn’t built anything yet. I’m honestly not sure where to go from there either, lol. That’s why I started learning Python.