Hacker News new | ask | show | jobs
by jmgao 1003 days ago
puts isn't applicable here because you actually need to format the %d, but any compiler worth using (i.e. not MSVC: https://gcc.godbolt.org/z/zx74vY1za) will optimize a printf of a constant string ending in a newline into a puts.
1 comments

No you don't need to format the %d. The same way you collapsed the loop into the constant 5, you collapse that printf into puts("5\n")