{"id":5847,"date":"2023-04-22T00:01:17","date_gmt":"2023-04-22T07:01:17","guid":{"rendered":"https:\/\/c-for-dummies.com\/blog\/?p=5847"},"modified":"2023-04-08T12:12:10","modified_gmt":"2023-04-08T19:12:10","slug":"the-final-output-to-html-code","status":"publish","type":"post","link":"https:\/\/c-for-dummies.com\/blog\/?p=5847","title":{"rendered":"The Final Output to HTML Code"},"content":{"rendered":"<p>The final update to the <em>sconvert<\/em> function includes translating characters <code>&amp;<\/code>, <code>&lt;<\/code>, and <code>&gt;<\/code> for proper HTML output. With this update to the code from <a href=\"https:\/\/c-for-dummies.com\/blog\/?p=5838\">last week&#8217;s Lesson<\/a>, the conversion filter is complete and can be used to translate C program text output into HTML code that I can easily post on the web.<br \/>\n<!--more--><br \/>\nThe update requires only these lines of code, added within the <em>switch-case<\/em> structure:<\/p>\n<pre class=\"screen\">\r\n            case '&amp;':\r\n                printf(\"&amp;amp;\");\r\n                offset++;\r\n                break;\r\n            case '&lt;':\r\n                printf(\"&amp;lt;\");\r\n                offset++;\r\n                break;\r\n            case '&gt;':\r\n                printf(\"&amp;gt;\");\r\n                offset++;\r\n                break;<\/pre>\n<p>To view the full code, <a href=\"https:\/\/github.com\/dangookin\/C-For-Dummies-Blog\/blob\/master\/2023_04_22-Lesson.c\" rel=\"noopener\" target=\"_blank\">click here<\/a> to visit my GitHub.<\/p>\n<p>The output doesn&#8217;t bother translating the newline (<code>\\n<\/code>) or return (<code>\\r<\/code>) into the <code>&lt;br&gt;<\/code> code. Honestly, the reason it doesn&#8217;t do so is that I&#8217;ve never needed it. When I run output through the <em>sconvert<\/em> utility, I&#8217;ve never had an issue with newlines mistranslating. So while it makes sense to convert them from an HTML formatting perspective, I&#8217;ve not needed to do so.<\/p>\n<p>This utility is one of my favorite types of things to code: a program that provides a solution to something that otherwise takes me a mountain of time. Most of these programs are just quick-and-dirty. In fact, I would say a majority of the programs I write for myself, to automate a task or perform some redundancy, are written in the shell scripting language. But for more complex programs, I enjoy sitting back and using my C skills to code a solution that saves me time and typing molecules. It&#8217;s handy, practical, and fun. That&#8217;s what I enjoy most about coding.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Considering all possible text output, here is the code that converts plain text into a semblance of HTML for posting on the web. <a href=\"https:\/\/c-for-dummies.com\/blog\/?p=5847\">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-5847","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\/5847","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=5847"}],"version-history":[{"count":2,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/5847\/revisions"}],"predecessor-version":[{"id":5855,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/5847\/revisions\/5855"}],"wp:attachment":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5847"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5847"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5847"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}