Posted to tcl by stwo at Wed Jul 31 03:33:56 GMT 2019view raw
- #include <stdio.h>
- int main (int argc, char *argv[]) {
- char s[] = "Fizz-Buzz";
- char *p;
- int i;
- for (i = 1; i < 101; i++) {
- p = s + sizeof s - 1;
- if (i % 5 == 0) {
- p = s + 5;
- s[4] = '-';
- } else {
- s[4] = '\0';
- }
- if (i % 3 == 0) {
- p = s;
- }
- if (!*p) {
- printf("%d ", i);
- } else {
- printf("%s ", p);
- }
- }
- return 0;
- }