Some small items, additional to the great review by Chux.
You don't seem to use anything from
<assert.h>
or<float.h>
, so no need to include those.The missing features are not documented anywhere, so we have to guess what subset of
printf()
is supported.Test cases are missing for ±infinity±∞ and not-a-number values with the
%f
specifier and for null pointers with the%s
specifier.Precision specifiers don't work properly with
%s
:myprintf("%.5s", "abcdefg"); // crashes
Unnecessary obfuscation:
*(s_p+1)
is much more recognisable when written ass_p[1]
.The fallthrough from
case '.'
todefault
causes the second conversion specifier to be printed literally in this example (and could be even more serious if the second conversion were%%
):myprintf("%.1f%f\n", 1.0, 0.0);