Get the length of a string with puts()
instead of strlen()
According to the standard C specification, puts()
returns a non-negative integer on success. In practice, most C libraries seem to treat puts(s)
as equivalent to printf("%s\n", s)
, which returns an integer equal to the number of bytes written.
As a result, the return value of puts(s)
is equal to 1 + strlen(s)
. If the additional console output can be ignored, this saves a few bytes.