There was a lot of despair tonight but I eventually finished day 2 part 1 of advent of code.
I successfully use strtok() to parse the input but the hardest part was a typo and a logic error.
I think I need a better way of walking through my code or maybe some unit testing to make sure what I think I'm doing is what I am actually doing.
@PHolder Thanks, I might try Cmocka. I think I’ve seen that in use somewhere before. It would have saved me at least a half hour and tons of printf statements. :)
@derickflorian Unit testing is very worthwhile. Even if you don't use a formal testing framework in C, you can still code methods just for testing your code and use a #define to change the flow of your code to invoke your test functionality.
#define UNITTEST
#ifdef UNITTEST
void assertEqual(...)
{
...
}
main(..) /* unit test main */
{
assertEqual(10,foo());
...
#else
main(...) /* real main */
{
...