raz / examples / Printf.raz

18 lines · 435 B · raw · history · last change 264716cb

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. *)
3module Printf;
4import Out, C;
5import SYSTEM;
6
7proc main*;
8var i: INT;
9begin
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;
16end;
17
18end Printf.