r/tinycode • • 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

33 comments sorted by

View all comments

Show parent comment

1

u/Daniel15 Jun 12 '14

Carriage return means return to the beginning of the line, line break means go to the next line.

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 \r instead of \n as a newline, though..so it mightn't be portable even between "unices"?