
{"id":19055,"date":"2022-08-03T19:22:38","date_gmt":"2022-08-03T13:52:38","guid":{"rendered":"https:\/\/beautifulworknew.wordpress.com\/?p=19055"},"modified":"2022-08-03T19:22:38","modified_gmt":"2022-08-03T13:52:38","slug":"using-streams-and-file-descriptors-with-fprintf-and-dprintf-respectively","status":"publish","type":"post","link":"https:\/\/www.trueangle.org\/index.php\/2022\/08\/03\/using-streams-and-file-descriptors-with-fprintf-and-dprintf-respectively\/","title":{"rendered":"Using streams and file descriptors with fprintf  and dprintf  respectively"},"content":{"rendered":"\n<p><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\n$ls\nascii-table.c   avg.txt               case-changer.c  env-var-set.c  functions_ver1.c  mph-to-kph.c     output.c\nascii-table.md  avg-with-garbage.txt  env-var.c       exist.sh       functions_ver2.c  mph-to-kph_v2.c\n$gcc output.c -o output\n$.\/output \nA regular message on stdout\nAlso a regular message on stdout\nAn error message on stderr\nA regular message, printed to fd 1\nAn error message, printed to fd 2\n$cat output.c \n#define _POSIX_C_SOURCE 200809L\n#include &lt;stdio.h&gt;\n\nint main(void)\n{\n   printf(\"A regular message on stdout\\n\");\n\n   \/* Using streams with fprintf() *\/\n   fprintf(stdout, \"Also a regular message on \" \n      \"stdout\\n\");\n   fprintf(stderr, \"An error message on stderr\\n\");\n\n   \/* Using file descriptors with dprintf().\n    * This requires _POSIX_C_SOURCE 200809L \n    * (man 3 dprintf)*\/\n   dprintf(1, \"A regular message, printed to \"\n      \"fd 1\\n\");\n   dprintf(2, \"An error message, printed to \"\n      \"fd 2\\n\");\n   return 0;\n}\n$\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>$ls ascii-table.c avg.txt case-changer.c env-var-set.c functions_ver1.c mph-to-kph.c output.c ascii-table.md avg-with-garbage.txt env-var.c exist.sh functions_ver2.c mph-to-kph_v2.c $gcc output.c -o output $.\/output A regular message on stdout Also a regular message on stdout An error message on stderr A regular message, printed to fd 1 An error message, printed to fd 2 $cat output.c #define _POSIX_C_SOURCE 200809L #include &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.trueangle.org\/index.php\/2022\/08\/03\/using-streams-and-file-descriptors-with-fprintf-and-dprintf-respectively\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Using streams and file descriptors with fprintf  and dprintf  respectively&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/19055"}],"collection":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/comments?post=19055"}],"version-history":[{"count":0,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/19055\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/media?parent=19055"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/categories?post=19055"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/tags?post=19055"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}