Very appreciative for the gentle encouragement of @PHolder to embark on the Advent of Code Challenge. I complete the first day of challenges using C.
One thing I was wondering is ok to post solutions to the challenges or no?
TIL:
- IBM has easy to understand C documentation that's less opaque than the Linux documentation for me. Example: https://www.ibm.com/docs/en/i/7.4?topic=functions-fgets-read-string
- sorting an array is not that easy. the function I used was qsort() and you have to implement a comparator. I adapted the comparator from here: https://en.cppreference.com/w/c/algorithm/qsort. The only difference is I used uint64_t for everything(not sure if it was the best choice but it had all the room I needed).
- To read a bunch of numbers from a file I couldn't get fscanf) to work well because it skipped over blank lines I read in as uint64_t so I couldn't figure out where each set of numbers ended. I had better luck with a combo of fgets() and stroull().
I actually really couldn't believe I finished it. The satisfaction of eventually getting something working in C is real!