Swift

Swift: How to flush the output of println on command line interface CLI

Just enable flush print all the time:

// -- Swift: clear output buffer for print all the time. Why is that not the default?
setbuf(__stdoutp, nil);

 

1. Testing:

If you have some print and/or println statementes in your code - these get's buffered.

Example:

1. print("Enter a name: ")

2. input user value

Output:

<--- just waiting for your input, after you hit ENTER, the text will appear:

"Enter name:"

It can be that you will be prompted for user input before the print statement get's printed on the screen. This is a bad thing. So execution is linear, but print and println use so called buffered outputs.

Swift missing feature: Why is this not just the default for command line interface applications?

 

M

Share
Published by
M

Recent Posts

Bibel Patch

Bibel Patch? Was ist das? Bibeln sind Übersetzungen und können auch Fehler enthalten. Nicht jede…

9 Jahren ago

SpeedreaderLTS – Speech Therapy Software for Logopedia

We write letters and words, but we pronounce syllables. With this method every child can…

10 Jahren ago

macOS Sierra – TOP 10 Features you MUST HAVE

macOS Sierra fixes also some tiny little silly bugs which is as good thing. TOP…

10 Jahren ago

Camino Alternative Dodo Browser Mac

Camino Alternative Dodo Browser Mac Click here https://www.flagsoft.com/cmswp/en/software/dodo-browser/ Camino, SeaMonkey, Maxthon Browser, Flock (web browser),…

10 Jahren ago

Real Time Mac Picture and Image Viewer for Event Photographers

Looking for Real Time Picture and Image Viewer for Event Photographers on your Mac? Click…

10 Jahren ago

PictureViewer with Real Time Viewing Event Images WiFi SD Card, eyefi

Real Time Event Photography - Real time pictures over WiFi SD Cards So you take…

10 Jahren ago