Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift: how to flush stdout after println?

Tags:

swift

How do I flush the stdout in Swift after a println command?

That is, what is the Swift equivalent of fflush(stdout) in C?

like image 730
Jukka Suomela Avatar asked Jun 11 '14 19:06

Jukka Suomela


People also ask

How do you flush a print?

The flush argument of the print() function can be set to True to stop the function from buffering the output data and forcibly flush it. If the flush argument is set to True , the print() function will not buffer the data to increase the efficiency and will keep flushing it on each call.

Does Scanf flush stdout?

Doing printf("Hello "); sleep(1); scanf("%c", &things); shows for me that indeed, with an interactive program scanf flushes stdout buffer.

Does python print flush stdout?

Each stdout. write and print operation will be automatically flushed afterwards.


1 Answers

You can use

fflush(stdout)

after you import libc:

#if os(Linux)
    import Glibc
#else
    import Darwin.C
#endif
like image 127
emlai Avatar answered Oct 28 '22 08:10

emlai