
{"id":19041,"date":"2022-08-01T02:32:32","date_gmt":"2022-07-31T21:02:32","guid":{"rendered":"https:\/\/beautifulworknew.wordpress.com\/?p=19041"},"modified":"2022-08-01T02:32:32","modified_gmt":"2022-07-31T21:02:32","slug":"exiting-a-program-with-relevant-return-value","status":"publish","type":"post","link":"https:\/\/www.trueangle.org\/index.php\/2022\/08\/01\/exiting-a-program-with-relevant-return-value\/","title":{"rendered":"Exiting a program with relevant  return value"},"content":{"rendered":"\n<p><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ls\nascii-table     avg.txt               case-changer.c  env-var-set    functions_ver1.c  mph-to-kph_v2.c\nascii-table.c   avg-with-garbage.txt  env-var         env-var-set.c  functions_ver2.c  output.c\nascii-table.md  case-changer          env-var.c       exist.sh       mph-to-kph.c\n$cat functions_ver1.c\n#include &lt;stdio.h&gt;\nint func1(void);\nint func2(void);\n\nint main(int argc, char *argv[])\n{\n   printf(\"Inside main\\n\");\n   printf(\"Calling function one\\n\");\n   if (func1())\n   {\n      printf(\"Everything ok from function one\\n\");\n      printf(\"Return with 0 from main - all ok\\n\");\n      return 0;\n   }\n   else\n   {\n      printf(\"Caught an error from function one\\n\");\n      printf(\"Return with 1 from main - error\\n\");\n      return 1;\n   }\n   return 0; \/* We shouldn't reach this, but \n                just in case *\/\n}\n\nint func1(void)\n{\n   printf(\"Inside function one\\n\");\n   printf(\"Calling function two\\n\");\n   if (func2())\n   {\n      printf(\"Everything ok from function two\\n\");\n      return 1;\n   }\n   else\n   {\n      printf(\"Caught an error from function two\\n\");\n      return 0;\n   }\n}\n\nint func2(void)\n{\n   printf(\"Inside function two\\n\");\n   printf(\"Returning with 0 (error) from \"\n      \"function two\\n\");\n   return 0;\n}\n$gcc functions_ver1.c -o functions_ver1.c \ngcc: fatal error: input file \u2018functions_ver1.c\u2019 is the same as output file\ncompilation terminated.\n$gcc functions_ver1.c -o functions_ver1\n$.\/functions_ver1 \nInside main\nCalling function one\nInside function one\nCalling function two\nInside function two\nReturning with 0 (error) from function two\nCaught an error from function two\nCaught an error from function one\nReturn with 1 from main - error\n$\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>$ls ascii-table avg.txt case-changer.c env-var-set functions_ver1.c mph-to-kph_v2.c ascii-table.c avg-with-garbage.txt env-var env-var-set.c functions_ver2.c output.c ascii-table.md case-changer env-var.c exist.sh mph-to-kph.c $cat functions_ver1.c #include &lt;stdio.h&gt; int func1(void); int func2(void); int main(int argc, char *argv[]) { printf(&#8220;Inside main\\n&#8221;); printf(&#8220;Calling function one\\n&#8221;); if (func1()) { printf(&#8220;Everything ok from function one\\n&#8221;); printf(&#8220;Return with 0 from main &#8211; all ok\\n&#8221;); return 0; &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.trueangle.org\/index.php\/2022\/08\/01\/exiting-a-program-with-relevant-return-value\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Exiting a program with relevant  return value&#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\/19041"}],"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=19041"}],"version-history":[{"count":0,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/19041\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/media?parent=19041"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/categories?post=19041"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/tags?post=19041"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}