digitalmars.D.learn - writef vs writeln and printing to the console
- Andrej Mitrovic (5/5) Jan 08 2011 Unfortunately I can't provide a simple test case, but I have a case wher...
- Jesse Phillips (2/11) Jan 08 2011 I don't think new line means to flush the buffer like it does in printf....
- Andrej Mitrovic (2/4) Jan 08 2011 Ok, that works. Thanks.
- Christopher Nicholson-Sauls (4/18) Jan 09 2011 What Jesse said, but also: I can't help wondering if there's a special
- Andrej Mitrovic (5/7) Jan 09 2011 Oh it's not a problem. I was converting some C code and it used
- Andrej Mitrovic (2/2) Jan 09 2011 *I meant I converted them to writef, not writefln, and got a different
- Christopher Nicholson-Sauls (7/9) Jan 09 2011 Okay, gotcha. I'll agree that the behavioral change is unexpected (when
Unfortunately I can't provide a simple test case, but I have a case where using: writef("..........\n"); inside a loop that runs a dozen times does not print out each line as the statement is reached, instead it prints out everything at once when the application is done. If I use this: writeln("........."); then I get each line printed out at the exact moment as this statement is reached. Is this normal behavior?
Jan 08 2011
Andrej Mitrovic Wrote:Unfortunately I can't provide a simple test case, but I have a case where using: writef("..........\n"); inside a loop that runs a dozen times does not print out each line as the statement is reached, instead it prints out everything at once when the application is done. If I use this: writeln("........."); then I get each line printed out at the exact moment as this statement is reached. Is this normal behavior?I don't think new line means to flush the buffer like it does in printf. I think you can use stdout.flush() from stdio;
Jan 08 2011
On 1/9/11, Jesse Phillips <jessekphillips+D gmail.com> wrote:I don't think new line means to flush the buffer like it does in printf. I think you can use stdout.flush() from stdio;Ok, that works. Thanks.
Jan 08 2011
On 01/08/11 17:03, Jesse Phillips wrote:Andrej Mitrovic Wrote:What Jesse said, but also: I can't help wondering if there's a special reason why you cannot (or would rather not) use writefln(".....")? -- Chris N-SUnfortunately I can't provide a simple test case, but I have a case where using: writef("..........\n"); inside a loop that runs a dozen times does not print out each line as the statement is reached, instead it prints out everything at once when the application is done. If I use this: writeln("........."); then I get each line printed out at the exact moment as this statement is reached. Is this normal behavior?I don't think new line means to flush the buffer like it does in printf. I think you can use stdout.flush() from stdio;
Jan 09 2011
On 1/9/11, Christopher Nicholson-Sauls <ibisbasenji gmail.com> wrote:What Jesse said, but also: I can't help wondering if there's a special reason why you cannot (or would rather not) use writefln(".....")?Oh it's not a problem. I was converting some C code and it used printf's with embedded newlines in the string. So I converted these to the safer writefln, but I got a different behavior when I compiled compared to the C version.
Jan 09 2011
*I meant I converted them to writef, not writefln, and got a different behavior*. writefln works fine.
Jan 09 2011
On 01/09/11 06:52, Andrej Mitrovic wrote:*I meant I converted them to writef, not writefln, and got a different behavior*. writefln works fine.Okay, gotcha. I'll agree that the behavioral change is unexpected (when coming from C). I believe there was actually a long discussion a while back on "to flush or not to flush" with regard to stdio functions, and apparently it was decided not to have the non *ln routines flush. Worth noting in the documentation if it isn't already. -- Chris N-S
Jan 09 2011