_(This answers tries to address good practices, but doesn't consider the question of "standard c". This answer is also specific to POSIX)_ # Standard constants Use `M_PI` from `math.h`, or define `PI` as `M_PI`. # Comments You could explain what the value `-.83` represents. Is it an angle? If so, is it in radians or degreses, and what does it measure. Maybe include a Wikipedia link. # Listen to compiler warnings These are from clang 15. See for yourself on [godbolt][1]. These are the ones I'd consider important: ``` <source>:39:9: warning: variable 'length' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] if (fp) { ``` Very important. ``` <source>:70:15: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32] len_rep = strlen(trg); ``` Follow the return type of `strlen` and use `size_t` for pointer-sized things. ``` <source>:155:29: warning: cast from 'const char *' to 'char *' drops const qualifier [-Wcast-qual] char *template = (char*)insert; ``` Declare `insert` as `char *`, not `const char *`, so the signature doesn't tell lies. ``` <source>:212:16: warning: implicit conversion loses floating-point precision: 'double' to 'float' [-Wimplicit-float-conversion] float N1 = floor(275*month/9); <source>:218:24: warning: implicit conversion loses floating-point precision: 'double' to 'float' [-Wimplicit-float-conversion] float lngHour = lng/15.0; ``` Be consistent and use either `float` or `double` consistently. Use `floorf` and `15.0f` for floats. ``` <source>:296:1: warning: non-void function does not return a value in all control paths [-Wreturn-type] } ``` This is about `days_in_month`. Think about what happens if the argument is 42. [1]: https://godbolt.org/#z:OYLghAFBqd5QCxAYwPYBMCmBRdBLAF1QCcAaPECAMzwBtMA7AQwFtMQByARg9KtQYEAysib0QXACx8BBAKoBnTAAUAHpwAMvAFYTStJg1AB9U8lJL6yAngGVG6AMKpaAVxYMQAJi%2BkHAGTwGTAA5dwAjTGIQSWkAB1QFQlsGZzcPb18EpJsBQOCwlkjo2ItMK1yGIQImYgI0908fMoqU6tqCfNCIqJjpBRq6hozmgY6uwuK%2BgEoLVFdiZHYOAFIvAGYsGmCAaiEARX8ASQAVbGMAeQBpHY0VjQBBADdUPHQdhQBHWkJMdeNUHFGBBpit1gAhe7PV7vL4/Ah/YzIWiJT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