{"id":1837,"date":"2015-06-15T10:41:42","date_gmt":"2015-06-15T08:41:42","guid":{"rendered":"http:\/\/www.flagsoft.com\/cmswp\/?p=1837"},"modified":"2016-10-20T13:07:46","modified_gmt":"2016-10-20T11:07:46","slug":"swift-how-to-flush-the-output-of-println-on-command-line-interface-cli","status":"publish","type":"post","link":"https:\/\/www.flagsoft.com\/cmswp\/swift-how-to-flush-the-output-of-println-on-command-line-interface-cli\/","title":{"rendered":"Swift: How to flush the output of println on command line interface CLI"},"content":{"rendered":"<p>Just enable flush print all the time:<\/p>\n<pre>\/\/ -- Swift: clear output buffer for print all the time. Why is that not the default?\r\nsetbuf(__stdoutp, nil);<\/pre>\n<p>&nbsp;<\/p>\n<p>1. Testing:<\/p>\n<p>If you have some print and\/or println statementes in your code - these get's buffered.<\/p>\n<p>Example:<\/p>\n<p>1. print(\"Enter a name: \")<\/p>\n<p>2. input user value<\/p>\n<p>Output:<\/p>\n<p>&lt;--- just waiting for your input, after you hit ENTER, the text will appear:<\/p>\n<p>\"Enter name:\"<\/p>\n<p>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.<\/p>\n<p>Swift missing feature: Why is this not just the default for command line interface applications?<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Just enable flush print all the time: \/\/ &#8212; Swift: clear output buffer for print all the time. Why is that not the default? setbuf(__stdoutp, nil); &nbsp; 1. Testing: If you have some print and\/or println statementes in your code &#8211; these get&#8217;s buffered. Example: 1. print(&#171;Enter a name: &#171;) 2. input user value Output: &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"https:\/\/www.flagsoft.com\/cmswp\/swift-how-to-flush-the-output-of-println-on-command-line-interface-cli\/\"> <span class=\"screen-reader-text\">Swift: How to flush the output of println on command line interface CLI<\/span> Weiterlesen &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"","_jetpack_memberships_contains_paid_content":false,"footnotes":"","_links_to":"","_links_to_target":""},"categories":[9],"tags":[],"class_list":["post-1837","post","type-post","status-publish","format-standard","hentry","category-swift"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Swift: How to flush the output of println on command line interface CLI - Flagsoft<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.flagsoft.com\/cmswp\/swift-how-to-flush-the-output-of-println-on-command-line-interface-cli\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Swift: How to flush the output of println on command line interface CLI - Flagsoft\" \/>\n<meta property=\"og:description\" content=\"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); &nbsp; 1. Testing: If you have some print and\/or println statementes in your code - these get&#039;s buffered. Example: 1. print(&quot;Enter a name: &quot;) 2. input user value Output: &hellip; Swift: How to flush the output of println on command line interface CLI Weiterlesen &raquo;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.flagsoft.com\/cmswp\/swift-how-to-flush-the-output-of-println-on-command-line-interface-cli\/\" \/>\n<meta property=\"og:site_name\" content=\"Flagsoft\" \/>\n<meta property=\"article:published_time\" content=\"2015-06-15T08:41:42+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2016-10-20T11:07:46+00:00\" \/>\n<meta name=\"author\" content=\"M\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Geschrieben von\" \/>\n\t<meta name=\"twitter:data1\" content=\"M\" \/>\n\t<meta name=\"twitter:label2\" content=\"Gesch\u00e4tzte Lesezeit\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 Minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.flagsoft.com\/cmswp\/swift-how-to-flush-the-output-of-println-on-command-line-interface-cli\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.flagsoft.com\/cmswp\/swift-how-to-flush-the-output-of-println-on-command-line-interface-cli\/\"},\"author\":{\"name\":\"M\",\"@id\":\"https:\/\/www.flagsoft.com\/cmswp\/#\/schema\/person\/01159effaa2678b9655388109ddf07f0\"},\"headline\":\"Swift: How to flush the output of println on command line interface CLI\",\"datePublished\":\"2015-06-15T08:41:42+00:00\",\"dateModified\":\"2016-10-20T11:07:46+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.flagsoft.com\/cmswp\/swift-how-to-flush-the-output-of-println-on-command-line-interface-cli\/\"},\"wordCount\":120,\"commentCount\":0,\"articleSection\":[\"Swift\"],\"inLanguage\":\"de-CH\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.flagsoft.com\/cmswp\/swift-how-to-flush-the-output-of-println-on-command-line-interface-cli\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.flagsoft.com\/cmswp\/swift-how-to-flush-the-output-of-println-on-command-line-interface-cli\/\",\"url\":\"https:\/\/www.flagsoft.com\/cmswp\/swift-how-to-flush-the-output-of-println-on-command-line-interface-cli\/\",\"name\":\"Swift: How to flush the output of println on command line interface CLI - Flagsoft\",\"isPartOf\":{\"@id\":\"https:\/\/www.flagsoft.com\/cmswp\/#website\"},\"datePublished\":\"2015-06-15T08:41:42+00:00\",\"dateModified\":\"2016-10-20T11:07:46+00:00\",\"author\":{\"@id\":\"https:\/\/www.flagsoft.com\/cmswp\/#\/schema\/person\/01159effaa2678b9655388109ddf07f0\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.flagsoft.com\/cmswp\/swift-how-to-flush-the-output-of-println-on-command-line-interface-cli\/#breadcrumb\"},\"inLanguage\":\"de-CH\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.flagsoft.com\/cmswp\/swift-how-to-flush-the-output-of-println-on-command-line-interface-cli\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.flagsoft.com\/cmswp\/swift-how-to-flush-the-output-of-println-on-command-line-interface-cli\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.flagsoft.com\/cmswp\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Swift: How to flush the output of println on command line interface CLI\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.flagsoft.com\/cmswp\/#website\",\"url\":\"https:\/\/www.flagsoft.com\/cmswp\/\",\"name\":\"Flagsoft\",\"description\":\"ALPHA Schulmagazin, Byztxt, Strongsdict, Remote Control Cursor for Mac, PictureViewer4Mac, sdspeed free SD Card Reader for Mac OS X, Byztxt Light, 1A Shopping List, Kindle Book Template\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.flagsoft.com\/cmswp\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"de-CH\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.flagsoft.com\/cmswp\/#\/schema\/person\/01159effaa2678b9655388109ddf07f0\",\"name\":\"M\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"de-CH\",\"@id\":\"https:\/\/www.flagsoft.com\/cmswp\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/3eea8d3678df652d127d9fa625eacfd1?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/3eea8d3678df652d127d9fa625eacfd1?s=96&d=mm&r=g\",\"caption\":\"M\"},\"url\":\"https:\/\/www.flagsoft.com\/cmswp\/author\/admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Swift: How to flush the output of println on command line interface CLI - Flagsoft","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.flagsoft.com\/cmswp\/swift-how-to-flush-the-output-of-println-on-command-line-interface-cli\/","og_locale":"de_DE","og_type":"article","og_title":"Swift: How to flush the output of println on command line interface CLI - Flagsoft","og_description":"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); &nbsp; 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: &hellip; Swift: How to flush the output of println on command line interface CLI Weiterlesen &raquo;","og_url":"https:\/\/www.flagsoft.com\/cmswp\/swift-how-to-flush-the-output-of-println-on-command-line-interface-cli\/","og_site_name":"Flagsoft","article_published_time":"2015-06-15T08:41:42+00:00","article_modified_time":"2016-10-20T11:07:46+00:00","author":"M","twitter_card":"summary_large_image","twitter_misc":{"Geschrieben von":"M","Gesch\u00e4tzte Lesezeit":"1 Minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.flagsoft.com\/cmswp\/swift-how-to-flush-the-output-of-println-on-command-line-interface-cli\/#article","isPartOf":{"@id":"https:\/\/www.flagsoft.com\/cmswp\/swift-how-to-flush-the-output-of-println-on-command-line-interface-cli\/"},"author":{"name":"M","@id":"https:\/\/www.flagsoft.com\/cmswp\/#\/schema\/person\/01159effaa2678b9655388109ddf07f0"},"headline":"Swift: How to flush the output of println on command line interface CLI","datePublished":"2015-06-15T08:41:42+00:00","dateModified":"2016-10-20T11:07:46+00:00","mainEntityOfPage":{"@id":"https:\/\/www.flagsoft.com\/cmswp\/swift-how-to-flush-the-output-of-println-on-command-line-interface-cli\/"},"wordCount":120,"commentCount":0,"articleSection":["Swift"],"inLanguage":"de-CH","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.flagsoft.com\/cmswp\/swift-how-to-flush-the-output-of-println-on-command-line-interface-cli\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.flagsoft.com\/cmswp\/swift-how-to-flush-the-output-of-println-on-command-line-interface-cli\/","url":"https:\/\/www.flagsoft.com\/cmswp\/swift-how-to-flush-the-output-of-println-on-command-line-interface-cli\/","name":"Swift: How to flush the output of println on command line interface CLI - Flagsoft","isPartOf":{"@id":"https:\/\/www.flagsoft.com\/cmswp\/#website"},"datePublished":"2015-06-15T08:41:42+00:00","dateModified":"2016-10-20T11:07:46+00:00","author":{"@id":"https:\/\/www.flagsoft.com\/cmswp\/#\/schema\/person\/01159effaa2678b9655388109ddf07f0"},"breadcrumb":{"@id":"https:\/\/www.flagsoft.com\/cmswp\/swift-how-to-flush-the-output-of-println-on-command-line-interface-cli\/#breadcrumb"},"inLanguage":"de-CH","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.flagsoft.com\/cmswp\/swift-how-to-flush-the-output-of-println-on-command-line-interface-cli\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.flagsoft.com\/cmswp\/swift-how-to-flush-the-output-of-println-on-command-line-interface-cli\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.flagsoft.com\/cmswp\/"},{"@type":"ListItem","position":2,"name":"Swift: How to flush the output of println on command line interface CLI"}]},{"@type":"WebSite","@id":"https:\/\/www.flagsoft.com\/cmswp\/#website","url":"https:\/\/www.flagsoft.com\/cmswp\/","name":"Flagsoft","description":"ALPHA Schulmagazin, Byztxt, Strongsdict, Remote Control Cursor for Mac, PictureViewer4Mac, sdspeed free SD Card Reader for Mac OS X, Byztxt Light, 1A Shopping List, Kindle Book Template","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.flagsoft.com\/cmswp\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"de-CH"},{"@type":"Person","@id":"https:\/\/www.flagsoft.com\/cmswp\/#\/schema\/person\/01159effaa2678b9655388109ddf07f0","name":"M","image":{"@type":"ImageObject","inLanguage":"de-CH","@id":"https:\/\/www.flagsoft.com\/cmswp\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/3eea8d3678df652d127d9fa625eacfd1?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3eea8d3678df652d127d9fa625eacfd1?s=96&d=mm&r=g","caption":"M"},"url":"https:\/\/www.flagsoft.com\/cmswp\/author\/admin\/"}]}},"jetpack_featured_media_url":"","uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"mailpoet_newsletter_max":false,"woocommerce_thumbnail":false,"woocommerce_single":false,"woocommerce_gallery_thumbnail":false,"yarpp-thumbnail":false,"slide-thumbnail":false},"uagb_author_info":{"display_name":"M","author_link":"https:\/\/www.flagsoft.com\/cmswp\/author\/admin\/"},"uagb_comment_info":19,"uagb_excerpt":"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); &nbsp; 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:&hellip;","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.flagsoft.com\/cmswp\/wp-json\/wp\/v2\/posts\/1837","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.flagsoft.com\/cmswp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.flagsoft.com\/cmswp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.flagsoft.com\/cmswp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.flagsoft.com\/cmswp\/wp-json\/wp\/v2\/comments?post=1837"}],"version-history":[{"count":0,"href":"https:\/\/www.flagsoft.com\/cmswp\/wp-json\/wp\/v2\/posts\/1837\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.flagsoft.com\/cmswp\/wp-json\/wp\/v2\/media?parent=1837"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.flagsoft.com\/cmswp\/wp-json\/wp\/v2\/categories?post=1837"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.flagsoft.com\/cmswp\/wp-json\/wp\/v2\/tags?post=1837"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}