Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • \$\begingroup\$ It feels like there should be a way to omit the ,0 arg to printf and just have it print whatever garbage was left. Or just spaces? But printf("%*c",i) prints a byte of garbage at the end, and we probably can't consider that a "terminator". Perhaps for(;i--;)puts(""); to use newline as the unary character? \$\endgroup\$ Commented Aug 14, 2023 at 22:44
  • \$\begingroup\$ Or if you want to write a function that returns a string instead of printing, perhaps memset(s,7,i);s[i]=0; to replace the input string with that many ASCII "BEL" characters and a terminator, but that might not be shorter. Or memset(...); return i; for an explicit-length string. (And relies on the caller to allocate a large enough buffer without having parsed the string of binary digits, so only a larger fixed-size buffer could work.) \$\endgroup\$ Commented Aug 14, 2023 at 22:47
  • 1
    \$\begingroup\$ @PeterCordes Good ideas, but I only managed to get the first one to work (leaving off ,0). Thanks anyways! \$\endgroup\$ Commented Aug 16, 2023 at 18:11
  • \$\begingroup\$ Doesn't seem to work anymore; 58 byte with spaces as digits \$\endgroup\$ Commented May 6, 2024 at 14:51
  • \$\begingroup\$ 55 bytes with Peter's suggestion of newline as unary char \$\endgroup\$ Commented May 6, 2024 at 14:56