{"id":2797,"date":"2017-11-11T00:01:39","date_gmt":"2017-11-11T08:01:39","guid":{"rendered":"http:\/\/c-for-dummies.com\/blog\/?p=2797"},"modified":"2017-12-23T07:57:48","modified_gmt":"2017-12-23T15:57:48","slug":"safe-coding-practices","status":"publish","type":"post","link":"https:\/\/c-for-dummies.com\/blog\/?p=2797","title":{"rendered":"Safe Coding Practices"},"content":{"rendered":"<p>Recently, I was notified of some weak programming practices common in beginning C material. As someone who appreciates solid code, I was surprised to hear about these items. As a teacher, I&#8217;m quick to address them.<br \/>\n<!--more--><br \/>\nFor the most part, my goal is to teach C by using small programs. This code is quick to type and easy to modify. The sample programs demonstrates specific topics and try not to boggle a beginner with too much crap or overwhelm someone who&#8217;s probably already intimidated.<\/p>\n<p>Because of my approach, I often cut corners with certain items. When I do, these issues are called out during the online presentations and in my books. I believe a difference exists between code that teaches and code you plan on releasing into the wild.<\/p>\n<p>The kind person who alerted me to these issues pointed out some issues in code I use to teach. He expressed his concerns, which are:<\/p>\n<ul>\n<li>Using <a href=\"http:\/\/c-for-dummies.com\/blog\/?p=2812\"><em>scanf()<\/em><\/a> to convert string data to numbers.<\/li>\n<li>Being mindful of how <a href=\"http:\/\/c-for-dummies.com\/blog\/?p=2816\"><em>strcpy()<\/em> and <em>strcat()<\/em><\/a> manipulate string data.<\/li>\n<li>Avoiding <em>putchar()<\/em> as a <a href=\"http:\/\/c-for-dummies.com\/blog\/?p=2871\">condition<\/a> in a <em>while<\/em> loop.<\/li>\n<\/ul>\n<p>These are three items I use when teaching C, and I see how each of them could lead to trouble. Nothing in my books or online movies presents a serious code threat. Yet, at the point where you use your coding skills in the real world, it helps to bolster your C knowledge with some safe programming practices in defense of things you might not anticipate.<\/p>\n<p>For a beginner, focus on learning C. The items listed above deserve a mention. Especially in the future, I will be more diligent about mentioning various weaknesses, which is something the C language has in abundance.<\/p>\n<p>The source cited for these safe coding practices is found on the <a href=\"https:\/\/www.securecoding.cert.org\/confluence\/display\/c\/SEI+CERT+C+Coding+Standard\" target=\"_new\">SEI Cert C Secure Coding Standards<\/a> website. For the three items bulleted above, I&#8217;ll go over the details over the next few weeks. I&#8217;ll cover other relevant and interesting items in the Secure Coding Standards document in all future material. After all, the goal of any programmer is to write safe and bulletproof code.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Bulletproofing your code is necessary and some common learning techniques can lead to trouble later if you&#8217;re careless. <a href=\"https:\/\/c-for-dummies.com\/blog\/?p=2797\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-2797","post","type-post","status-publish","format-standard","hentry","category-main"],"_links":{"self":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2797","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2797"}],"version-history":[{"count":8,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2797\/revisions"}],"predecessor-version":[{"id":2887,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2797\/revisions\/2887"}],"wp:attachment":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2797"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2797"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2797"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}