Post History
C (gcc), 232 bytes f(n,w,p){printf("%i bottle%s of beer%s%s",n,"s"+(n<2)," on the wall"+w,p);}main(i){for(i=99;i;){f(i,0,", ");f(i,12,".\n");printf(i>1?"Take one down and pass it around, "...
Answer
#1: Initial revision
# [C (gcc)], 232 bytes <!-- language-all: lang-c --> f(n,w,p){printf("%i bottle%s of beer%s%s",n,"s"+(n<2)," on the wall"+w,p);}main(i){for(i=99;i;){f(i,0,", ");f(i,12,".\n");printf(i>1?"Take one down and pass it around, ":"Go to the store and buy some more, ");f(--i?:99,0,".\n\n");}} [Try it online!][TIO-ksogzxyr] Main golfing techniques: * The repetitive part has been put into a function * conditional strings are sometimes implemented using pointer arithmetic, using the fact that C strings are zero terminated character arrays * The code uses the implicit int rule * I'm passing a pointer through an int argument which then in turn is interpreted as a pointer by `printf` (not portable and definitely not clean; allows me to use the implicit int rule for that argument) * The gcc extension `condition?:value` (give `condition` unless that is zero, in which case give `value`) is used to save one character * The printf function is declared implicitly (which isn't guaranteed to work by any C standard, but works just fine in practice by any compiler that allows implicit declarations), saving the 18 characters that would otherwise be needed for `#include<stdio.h>` (including the mandatory line break following that directive) [C (gcc)]: https://gcc.gnu.org/ [TIO-ksogzxyr]: https://tio.run/##Lc3BjoJADAbgV2makAyxbNQbsrsefQGPexlg0EZoycwYYgzPzg7EW/@m/b@muDXNsnRGaKIxf4@eJXYGM4ZaY@xdFkA7qJ3zWcgCkhAG3Bn5PuaEoALx7mCyfY@7taCaB8tiOH936g3/lGXFVQqGaU9IgHm1zocj4defpPQB@fdwxqt9uFTpoNVJwEoLow0BOIL1@pQ2vZ/wohB1U0NU77az@vmCoIODIW0@SFHw@VSWK5ukzZrnZfkH "C (gcc) – Try It Online"