{"id":65,"date":"2015-07-13T12:32:35","date_gmt":"2015-07-13T11:32:35","guid":{"rendered":"http:\/\/watchdiana.fail\/blog\/?p=65"},"modified":"2015-07-29T12:19:43","modified_gmt":"2015-07-29T11:19:43","slug":"learn-c-the-hard-way-a-lesson-where-i-cant-do-too-much-maybe","status":"publish","type":"post","link":"https:\/\/watchdiana.fail\/blog\/2015\/07\/13\/learn-c-the-hard-way-a-lesson-where-i-cant-do-too-much-maybe\/","title":{"rendered":"Learn C the Hard Way &#8211; a lesson where I can&#8217;t do too much.  Maybe"},"content":{"rendered":"<p>Ex 8:<\/p>\n<p>This is harder for me to type out with my brain switched off, as it&#8217;s new to me so I want to understand it.  It&#8217;s been pointed out that my wish to understand everything immediately is leading me off down blind alleys.  Well, yes.  That&#8217;s true.  I shall try harder not to step off the path, and to trust this book to lead me to where I need to go.  I find it hard to stop on the external resea&#8230; OK, I find it hard to stop on anything.  But I can, so I should.  One big risk is that I&#8217;ll learn too far ahead and hit a lesson that should be teaching me, and I&#8217;ll basically just skim it.  I&#8217;ve fallen prey to that a lot before.  A little learning is a dangerous thing.  Although sometimes it can get you cash on game shows, so it&#8217;s not all bad.<\/p>\n<p>Extra Credit:<\/p>\n<p>Embedding a null byte in the char name[] increases its size but stops us from reading everything after the null character.<\/p>\n<p>It&#8217;s easier to get garbage out of an int than out of a char.  I can call for item n+4 out of n in a list of integers and get back what looks like a sensible integer.<\/p>\n<p>If I define an array, I&#8217;m defining its size.  I can then write out over the end of it, and it stays at the same size (there is a null byte) but I can also pick from it.  This gets by the compiler and valgrind.  There must be ways of stopping it, presumably tests I can write or flags or some other tool.<\/p>\n<p>Playing with putting characters into ints and ints into characters is&#8230; less frustrating than in Python, but probably more dangerous.  Python protects me from myself.  Here, I can easily put in a character that means something and have it be formatted and it looks right, and it&#8217;s just from the wrong place entirely.  So I&#8217;m pretty damned sure there will be ways of dealing with that.  What I need to take from this is that I&#8217;ve got the ability to feed X into Y and Y will just chomp it up and not worry about the flavour.<\/p>\n<p>&#8212;<\/p>\n<p>Other stuff:<\/p>\n<p>I&#8217;m pretty sure that I will use something like sizeof() in the Arduino, if I want to make an array of my LEDs.  Sparky needs visual output.  Either that or explicit sizing of the &#8230; oh.  I think I triggered an error over fitting everything into an explicitly sized array when I tried that last time.  I probably didn&#8217;t have the null character accounted for.  So I could try that next time I&#8217;m sitting down to program Sparky.  That&#8217;ll deal with the error where things are the wrong size, and I can look at why they are really not working instead.  Sparky&#8217;s next due for a look this evening or on Tuesday.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ex 8: This is harder for me to type out with my brain switched off, as it&#8217;s new to me so I want to understand it. It&#8217;s been pointed out that my wish to understand everything immediately is leading me off down blind alleys. Well, yes. That&#8217;s true. I shall try harder not to step [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,29],"tags":[7,9,11,12,23,13],"class_list":["post-65","post","type-post","status-publish","format-standard","hentry","category-coding","category-sparky","tag-c","tag-coding","tag-learn-c-the-hard-way","tag-sparky","tag-things-i-do-at-makespace","tag-things-i-do-because-im-stubborn","missing-thumbnail"],"_links":{"self":[{"href":"https:\/\/watchdiana.fail\/blog\/wp-json\/wp\/v2\/posts\/65","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/watchdiana.fail\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/watchdiana.fail\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/watchdiana.fail\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/watchdiana.fail\/blog\/wp-json\/wp\/v2\/comments?post=65"}],"version-history":[{"count":2,"href":"https:\/\/watchdiana.fail\/blog\/wp-json\/wp\/v2\/posts\/65\/revisions"}],"predecessor-version":[{"id":122,"href":"https:\/\/watchdiana.fail\/blog\/wp-json\/wp\/v2\/posts\/65\/revisions\/122"}],"wp:attachment":[{"href":"https:\/\/watchdiana.fail\/blog\/wp-json\/wp\/v2\/media?parent=65"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/watchdiana.fail\/blog\/wp-json\/wp\/v2\/categories?post=65"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/watchdiana.fail\/blog\/wp-json\/wp\/v2\/tags?post=65"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}