{"id":68,"date":"2021-05-07T13:29:50","date_gmt":"2021-05-07T13:29:50","guid":{"rendered":"https:\/\/danielpgleason.com\/?p=68"},"modified":"2021-05-07T13:29:50","modified_gmt":"2021-05-07T13:29:50","slug":"what-is-c-kr-syntax","status":"publish","type":"post","link":"https:\/\/danielpgleason.com\/index.php\/2021\/05\/07\/what-is-c-kr-syntax\/","title":{"rendered":"What is C K&#038;R Syntax?"},"content":{"rendered":"\n<p>Okay I just want to start out and say that this is outdated. The only reason why I am posting about this is because I find the history of technology very interesting and I want to share what I&#8217;ve read up on. <\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Alright so, if you&#8217;re a programmer you&#8217;re probably aware of multiple types of syntax. With Python we have:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism lang-python\" data-lang=\"Python\"><code>def MyFunction:\n    print(&quot;Hello World&quot;)\n\nMyFunction()<\/code><\/pre><\/div>\n\n\n\n<p>In Java we have:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism lang-plain\"><code>public static void main(String[] args)\n{\n    Chicken();\n}\n\nvoid Chicken()\n{\n    System.out.println(&quot;Hello World&quot;);\n}<\/code><\/pre><\/div>\n\n\n\n<p>In standard C\/C++ we have:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism lang-cpp\" data-lang=\"C++\"><code>int main(void)\n{\n    printf(&quot;Hello World&quot;);\n    return 0;\n}<\/code><\/pre><\/div>\n\n\n\n<p>But in the old days we had something called K &amp; R syntax in C. It looked like this:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism lang-c\" data-lang=\"C\"><code>int Chicken(a, b, c)\nint a;\nfloat b;\nchar c;\n{\n   return 0;\n}<\/code><\/pre><\/div>\n\n\n\n<p>What&#8217;s interesting about this is that some modern compilers still support this syntax but will scream at you and tell you to not do it.  However there&#8217;s some important things to note here. Look at the following code block. <\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism lang-c\" data-lang=\"C\"><code>int Chicken(a,b,c)\nint a;\nint b;\n{\n\n}<\/code><\/pre><\/div>\n\n\n\n<p>If you notice, I never declared the data type for c. By default, the compiler will use integer data types for anything that is undeclared. So the entire concept behind K &amp; R syntax is that you define the function name, and it&#8217;s inputs. Then, you define the types of inputs afterwards. It&#8217;s very different from what I was taught in university. I just wanted to share this. Hopefully someone finds this interesting. \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Okay I just want to start out and say that this is outdated. The only reason why I am posting about this is because I find the history of technology very interesting and I want to share what I&#8217;ve read up on. Alright so, if you&#8217;re a programmer you&#8217;re probably aware of multiple types of &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/danielpgleason.com\/index.php\/2021\/05\/07\/what-is-c-kr-syntax\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;What is C K&#038;R Syntax?&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-68","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/danielpgleason.com\/index.php\/wp-json\/wp\/v2\/posts\/68"}],"collection":[{"href":"https:\/\/danielpgleason.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/danielpgleason.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/danielpgleason.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/danielpgleason.com\/index.php\/wp-json\/wp\/v2\/comments?post=68"}],"version-history":[{"count":1,"href":"https:\/\/danielpgleason.com\/index.php\/wp-json\/wp\/v2\/posts\/68\/revisions"}],"predecessor-version":[{"id":69,"href":"https:\/\/danielpgleason.com\/index.php\/wp-json\/wp\/v2\/posts\/68\/revisions\/69"}],"wp:attachment":[{"href":"https:\/\/danielpgleason.com\/index.php\/wp-json\/wp\/v2\/media?parent=68"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/danielpgleason.com\/index.php\/wp-json\/wp\/v2\/categories?post=68"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/danielpgleason.com\/index.php\/wp-json\/wp\/v2\/tags?post=68"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}