| 1 | (* Out and C's printf, writing to the same standard output. Each keeps |
| 2 | a buffer of its own, so each is flushed before the other writes. *) |
| 3 | module Printf; |
| 4 | import Out, C; |
| 5 | import SYSTEM; |
| 6 | |
| 7 | proc main*; |
| 8 | var i: INT; |
| 9 | begin |
| 10 | for i := 1 to 3 do |
| 11 | Out.str("raz says "); Out.int(i); Out.ln; |
| 12 | Out.flush; |
| 13 | _ := C.printf("C says %d, %s\n", I32(i * i), "squared"); |
| 14 | _ := C.fflush(C.stdout); |
| 15 | end; |
| 16 | end; |
| 17 | |
| 18 | end Printf. |