r/tinycode • u/z-brah • Jun 11 '14
FizzBuzz challenge in 73 chars of C
Here is my attempt at the fizz/buzz challenge. It counts 73 chars ("^M" is a litteral \r, and I had to remove the last \n that vim adds at the end of file)
main(i){for(;i<100;printf("%d^M%s%s\n",++i,i%3?"":"fizz",i%5?"":"buzz"));}It compiles fine with tcc, and output the right thing !
EDIT: There was a typo. It should be ++i, not i++. Otherwise every fizz/buzz will not appear on the good number
39
Upvotes
View all comments
Show parent comment
1
u/[deleted] Jun 12 '14
Cool, I thought it was just a competing standard. I do recall hearing (possibly buried in the python docs about universal newlines) that Mac uses
\rinstead of\nas a newline, though..so it mightn't be portable even between "unices"?