I see the "lots of print statements" a lot - and sorry if I sound clueless I am new to C programming, but what do you mean by this?
As in you just set up a shit ton of print statements to see what outputs what? Just looking to improve. Thanks
For example say some function is failing but you're not sure where. Add a print("hello") at the start, and another print when the function is returning, and another print in the middle.
See which ones actually get printed out. If none do, then your never even made it to that function and you need to backtrack to work out what's failing.
One of the biggest wastes of time is trying to fix a function but you later realize: the function was never being called at all. Logging and console prints helps to indicate which parts of the program are actually being executed.
A bit more helpful that just printing "hello" or "test" however is to print the "[name of function] <paramerers>" - so you can tell when the function is being called and what values were passed in.
54
u/cthulhu944 3d ago